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