feat(i18n): calculator.js, timer.js, image-ref.js auf t() umstellen
This commit is contained in:
@@ -69,7 +69,7 @@ const Calculator = {
|
||||
|
||||
const widgetId = WidgetManager.create('calculator', {
|
||||
id: this.WIDGET_ID,
|
||||
title: 'Taschenrechner',
|
||||
title: t('calculator.title'),
|
||||
x: saved.x || 400,
|
||||
y: saved.y || 120,
|
||||
width: saved.width || 280,
|
||||
@@ -214,7 +214,7 @@ const Calculator = {
|
||||
|
||||
const title = document.createElement('div');
|
||||
title.className = 'calc-history-title';
|
||||
title.textContent = 'History';
|
||||
title.textContent = t('calculator.history');
|
||||
container.appendChild(title);
|
||||
|
||||
this._renderHistoryItems(container);
|
||||
@@ -345,7 +345,7 @@ const Calculator = {
|
||||
|
||||
const result = this._evaluate(this._currentExpr);
|
||||
if (result === null) {
|
||||
this._lastResult = 'Fehler';
|
||||
this._lastResult = t('calculator.error');
|
||||
this._updateDisplay();
|
||||
return;
|
||||
}
|
||||
|
||||
+22
-22
@@ -114,8 +114,8 @@ const ImageRef = {
|
||||
} catch (e) {
|
||||
console.warn('ImageRef: sessionStorage Write fehlgeschlagen', e);
|
||||
HellionDialog.alert(
|
||||
'Bild konnte nicht gespeichert werden. Der Browser-Speicher ist voll.',
|
||||
{ type: 'danger', title: 'Speicherfehler' }
|
||||
t('imageref.storage_error'),
|
||||
{ type: 'danger', title: t('imageref.storage_error.title') }
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -144,8 +144,8 @@ const ImageRef = {
|
||||
|
||||
if (this._images.length >= this.MAX_IMAGES) {
|
||||
await HellionDialog.alert(
|
||||
'Maximal ' + this.MAX_IMAGES + ' Bild-Widgets gleichzeitig. Schliesse eines um ein neues zu oeffnen.',
|
||||
{ type: 'warning', title: 'Limit erreicht' }
|
||||
t('imageref.limit', { max: this.MAX_IMAGES }),
|
||||
{ type: 'warning', title: t('imageref.limit.title') }
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -172,8 +172,8 @@ const ImageRef = {
|
||||
dataUrl = await this._processFile(file);
|
||||
} catch (err) {
|
||||
await HellionDialog.alert(
|
||||
'Bild konnte nicht geladen werden: ' + err.message,
|
||||
{ type: 'danger', title: 'Bildfehler' }
|
||||
t('imageref.load_error', { error: err.message }),
|
||||
{ type: 'danger', title: t('imageref.load_error.title') }
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ const ImageRef = {
|
||||
_createWidget(imageData, dataUrl) {
|
||||
WidgetManager.create('image', {
|
||||
id: imageData.id,
|
||||
title: imageData.label || 'Bild-Referenz',
|
||||
title: imageData.label || t('imageref.title'),
|
||||
x: imageData.x,
|
||||
y: imageData.y,
|
||||
width: imageData.width,
|
||||
@@ -249,14 +249,14 @@ const ImageRef = {
|
||||
const img = document.createElement('img');
|
||||
img.className = 'imgref-img';
|
||||
img.src = dataUrl;
|
||||
img.alt = imageData.label || 'Bild-Referenz';
|
||||
img.alt = imageData.label || t('imageref.title');
|
||||
wrapper.appendChild(img);
|
||||
|
||||
// Bild ersetzen Button
|
||||
const replaceBtn = document.createElement('button');
|
||||
replaceBtn.className = 'imgref-replace-btn';
|
||||
replaceBtn.type = 'button';
|
||||
replaceBtn.textContent = 'Bild ersetzen';
|
||||
replaceBtn.textContent = t('imageref.replace');
|
||||
replaceBtn.addEventListener('click', async () => {
|
||||
const file = await this._pickFile();
|
||||
if (!file) return;
|
||||
@@ -266,8 +266,8 @@ const ImageRef = {
|
||||
this.renderBody(imageData, bodyEl, newDataUrl);
|
||||
} catch (err) {
|
||||
await HellionDialog.alert(
|
||||
'Bild konnte nicht geladen werden: ' + err.message,
|
||||
{ type: 'danger', title: 'Bildfehler' }
|
||||
t('imageref.load_error', { error: err.message }),
|
||||
{ type: 'danger', title: t('imageref.load_error.title') }
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -283,7 +283,7 @@ const ImageRef = {
|
||||
const label = document.createElement('input');
|
||||
label.className = 'imgref-label';
|
||||
label.type = 'text';
|
||||
label.placeholder = 'Beschriftung (optional)';
|
||||
label.placeholder = t('imageref.label_placeholder');
|
||||
label.maxLength = 100;
|
||||
label.value = imageData.label || '';
|
||||
|
||||
@@ -295,8 +295,8 @@ const ImageRef = {
|
||||
const entry = WidgetManager._widgets.get(imageData.id);
|
||||
if (entry) {
|
||||
const titleEl = entry.el.querySelector('.widget-title-text');
|
||||
if (titleEl) titleEl.textContent = text || 'Bild-Referenz';
|
||||
entry.state.title = text || 'Bild-Referenz';
|
||||
if (titleEl) titleEl.textContent = text || t('imageref.title');
|
||||
entry.state.title = text || t('imageref.title');
|
||||
}
|
||||
|
||||
this._debouncedSave();
|
||||
@@ -321,7 +321,7 @@ const ImageRef = {
|
||||
icon.textContent = '\uD83D\uDDBC\uFE0F';
|
||||
|
||||
const text = document.createElement('span');
|
||||
text.textContent = 'Klicken oder Bild hierher ziehen';
|
||||
text.textContent = t('imageref.dropzone');
|
||||
|
||||
dropzone.append(icon, text);
|
||||
|
||||
@@ -336,8 +336,8 @@ const ImageRef = {
|
||||
await this.save();
|
||||
} catch (err) {
|
||||
await HellionDialog.alert(
|
||||
'Bild konnte nicht geladen werden: ' + err.message,
|
||||
{ type: 'danger', title: 'Bildfehler' }
|
||||
t('imageref.load_error', { error: err.message }),
|
||||
{ type: 'danger', title: t('imageref.load_error.title') }
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -363,8 +363,8 @@ const ImageRef = {
|
||||
const file = e.dataTransfer.files[0];
|
||||
if (!file || !file.type.startsWith('image/')) {
|
||||
await HellionDialog.alert(
|
||||
'Bitte eine Bilddatei verwenden (PNG, JPG, WebP, etc.).',
|
||||
{ type: 'warning', title: 'Kein Bild' }
|
||||
t('imageref.invalid_file'),
|
||||
{ type: 'warning', title: t('imageref.invalid_file.title') }
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -376,8 +376,8 @@ const ImageRef = {
|
||||
await this.save();
|
||||
} catch (err) {
|
||||
await HellionDialog.alert(
|
||||
'Bild konnte nicht geladen werden: ' + err.message,
|
||||
{ type: 'danger', title: 'Bildfehler' }
|
||||
t('imageref.load_error', { error: err.message }),
|
||||
{ type: 'danger', title: t('imageref.load_error.title') }
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -433,7 +433,7 @@ const ImageRef = {
|
||||
|
||||
img.onerror = () => {
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
reject(new Error('Bild konnte nicht geladen werden'));
|
||||
reject(new Error(t('imageref.load_error', { error: 'unknown' })));
|
||||
};
|
||||
|
||||
img.src = objectUrl;
|
||||
|
||||
+17
-17
@@ -82,7 +82,7 @@ const Timer = {
|
||||
|
||||
WidgetManager.create('timer', {
|
||||
id: this.WIDGET_ID,
|
||||
title: 'Timer',
|
||||
title: t('timer.title'),
|
||||
x: saved.x || 600,
|
||||
y: saved.y || 80,
|
||||
width: saved.width || 260,
|
||||
@@ -190,7 +190,7 @@ const Timer = {
|
||||
const btnStart = document.createElement('button');
|
||||
btnStart.className = 'timer-ctrl-btn primary';
|
||||
btnStart.type = 'button';
|
||||
btnStart.textContent = 'Start';
|
||||
btnStart.textContent = t('timer.start');
|
||||
btnStart.addEventListener('click', () => {
|
||||
if (!this._running && this._remaining === 0) {
|
||||
this._applyInput();
|
||||
@@ -202,7 +202,7 @@ const Timer = {
|
||||
const btnPause = document.createElement('button');
|
||||
btnPause.className = 'timer-ctrl-btn';
|
||||
btnPause.type = 'button';
|
||||
btnPause.textContent = 'Pause';
|
||||
btnPause.textContent = t('timer.pause');
|
||||
btnPause.disabled = true;
|
||||
btnPause.addEventListener('click', () => this._pause());
|
||||
this._btnPause = btnPause;
|
||||
@@ -210,7 +210,7 @@ const Timer = {
|
||||
const btnReset = document.createElement('button');
|
||||
btnReset.className = 'timer-ctrl-btn danger';
|
||||
btnReset.type = 'button';
|
||||
btnReset.textContent = 'Reset';
|
||||
btnReset.textContent = t('timer.reset');
|
||||
btnReset.addEventListener('click', () => this._reset());
|
||||
this._btnReset = btnReset;
|
||||
|
||||
@@ -253,13 +253,13 @@ const Timer = {
|
||||
|
||||
const title = document.createElement('span');
|
||||
title.className = 'timer-presets-title';
|
||||
title.textContent = 'Presets';
|
||||
title.textContent = t('timer.presets');
|
||||
|
||||
const addBtn = document.createElement('button');
|
||||
addBtn.className = 'timer-preset-add';
|
||||
addBtn.type = 'button';
|
||||
addBtn.textContent = '+';
|
||||
addBtn.title = 'Preset speichern';
|
||||
addBtn.title = t('timer.save_preset');
|
||||
addBtn.addEventListener('click', () => this._showAddPreset(container));
|
||||
|
||||
header.append(title, addBtn);
|
||||
@@ -322,8 +322,8 @@ const Timer = {
|
||||
|
||||
if (this._presets.length >= this.MAX_PRESETS) {
|
||||
HellionDialog.alert(
|
||||
'Maximale Anzahl erreicht! Du kannst maximal ' + this.MAX_PRESETS + ' Presets speichern.',
|
||||
{ type: 'warning', title: 'Limit erreicht' }
|
||||
t('timer.limit_message', { max: this.MAX_PRESETS }),
|
||||
{ type: 'warning', title: t('timer.limit_title') }
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -334,8 +334,8 @@ const Timer = {
|
||||
const parsed = this._parseTimeInput(this._inputEl.value);
|
||||
if (parsed === 0) {
|
||||
HellionDialog.alert(
|
||||
'Gib zuerst eine Zeit ein, bevor du ein Preset speicherst.',
|
||||
{ type: 'info', title: 'Keine Zeit' }
|
||||
t('timer.no_time_message'),
|
||||
{ type: 'info', title: t('timer.no_time_title') }
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -347,13 +347,13 @@ const Timer = {
|
||||
const nameInput = document.createElement('input');
|
||||
nameInput.className = 'timer-add-input';
|
||||
nameInput.type = 'text';
|
||||
nameInput.placeholder = 'Name...';
|
||||
nameInput.placeholder = t('timer.preset_name_placeholder');
|
||||
nameInput.maxLength = 20;
|
||||
|
||||
const confirmBtn = document.createElement('button');
|
||||
confirmBtn.className = 'timer-add-confirm';
|
||||
confirmBtn.type = 'button';
|
||||
confirmBtn.textContent = 'OK';
|
||||
confirmBtn.textContent = t('timer.ok');
|
||||
|
||||
const doAdd = async () => {
|
||||
const name = nameInput.value.trim();
|
||||
@@ -508,9 +508,9 @@ const Timer = {
|
||||
_startTitleBlink() {
|
||||
this._originalTitle = document.title;
|
||||
this._blinkIntervalId = setInterval(() => {
|
||||
document.title = document.title === '[!] Timer abgelaufen'
|
||||
document.title = document.title === t('timer.finished_title')
|
||||
? this._originalTitle
|
||||
: '[!] Timer abgelaufen';
|
||||
: t('timer.finished_title');
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
@@ -521,7 +521,7 @@ const Timer = {
|
||||
if (this._blinkIntervalId) {
|
||||
clearInterval(this._blinkIntervalId);
|
||||
this._blinkIntervalId = null;
|
||||
document.title = this._originalTitle || 'Hellion Dashboard';
|
||||
document.title = this._originalTitle || t('timer.default_page_title');
|
||||
}
|
||||
this._finished = false;
|
||||
this._updateDisplay();
|
||||
@@ -534,7 +534,7 @@ const Timer = {
|
||||
_updateMuteBtn() {
|
||||
if (!this._muteBtn) return;
|
||||
this._muteBtn.textContent = this._muted ? '\uD83D\uDD07' : '\uD83D\uDD0A';
|
||||
this._muteBtn.title = this._muted ? 'Ton einschalten' : 'Ton ausschalten';
|
||||
this._muteBtn.title = this._muted ? t('timer.unmute') : t('timer.mute');
|
||||
this._muteBtn.classList.toggle('muted', this._muted);
|
||||
},
|
||||
|
||||
@@ -555,7 +555,7 @@ const Timer = {
|
||||
_updateControls() {
|
||||
if (this._btnStart) {
|
||||
this._btnStart.disabled = this._running;
|
||||
this._btnStart.textContent = this._finished ? 'Neustart' : 'Start';
|
||||
this._btnStart.textContent = this._finished ? t('timer.restart') : t('timer.start');
|
||||
}
|
||||
if (this._btnPause) {
|
||||
this._btnPause.disabled = !this._running;
|
||||
|
||||
Reference in New Issue
Block a user