fix: Popup-Action-Icons riesig, "copy" als Text — Cache-Robustheit
Wenn der Browser noch die alte CSS bzw. i18n.js aus dem Cache hatte, lief das neu strukturierte Popup ins Leere: - SVGs ohne CSS-Width-Constraint nahmen die Browser-Standardgröße (300×150) an → riesige Icons, Layout brach in Vertikalstapel - Der Key "copy" fehlte in der alten i18n.js → "Kopieren" wurde durch den Roh-Key "copy" ersetzt Robust gemacht: - SVGs der Action-Buttons bekommen jetzt direkt im HTML width="16" height="16" — funktioniert auch ohne dass die zugehörige CSS-Regel geladen wurde - applyLang() in i18n.js fällt bei fehlendem Schlüssel auf den HTML-Default-Text zurück, anstatt den Key als Text einzuschreiben (gleiches Prinzip für data-i18n, -i18n-ph, -i18n-title) Version v15 → v16.
This commit is contained in:
@@ -442,15 +442,26 @@ export function t(key, vars = {}) {
|
||||
return val.replace(/\{(\w+)\}/g, (_, k) => vars[k] ?? '');
|
||||
}
|
||||
|
||||
// Look up a translation but return null if the key is undefined in both
|
||||
// the current language and German. Lets callers fall back to the existing
|
||||
// HTML default rather than displaying the raw key.
|
||||
function tOrNull(key) {
|
||||
const dict = translations[currentLang] ?? translations.de;
|
||||
const val = dict[key] ?? translations.de[key];
|
||||
return typeof val === 'string' ? val : null;
|
||||
}
|
||||
|
||||
export function applyLang() {
|
||||
document.querySelectorAll('[data-i18n]').forEach(el => {
|
||||
const v = t(el.dataset.i18n);
|
||||
if (typeof v === 'string') el.textContent = v;
|
||||
const v = tOrNull(el.dataset.i18n);
|
||||
if (v != null) el.textContent = v;
|
||||
});
|
||||
document.querySelectorAll('[data-i18n-ph]').forEach(el => {
|
||||
el.placeholder = t(el.dataset.i18nPh);
|
||||
const v = tOrNull(el.dataset.i18nPh);
|
||||
if (v != null) el.placeholder = v;
|
||||
});
|
||||
document.querySelectorAll('[data-i18n-title]').forEach(el => {
|
||||
el.title = t(el.dataset.i18nTitle);
|
||||
const v = tOrNull(el.dataset.i18nTitle);
|
||||
if (v != null) el.title = v;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
// Increment APP_VERSION with every code change
|
||||
export const APP_VERSION = 'v15';
|
||||
export const APP_VERSION = 'v16';
|
||||
|
||||
Reference in New Issue
Block a user