Console: English only in EN mode (chrome, crumb, toast)
The shared chrome, the same in all six modules: the tab title and <html lang>, the language button's title / aria-label (data-no-i18n, so set in code by localizeChrome()), the search tooltip, the breadcrumb (setCrumb() now localizes the top bar) and toast(), which wrote outside every localize() root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
31ecd59ca6
commit
9fcec732d0
+16
-1
@@ -61,7 +61,7 @@ async function api(method, path, body) {
|
||||
|
||||
function toast(msg) {
|
||||
const t = $('toast');
|
||||
t.innerHTML = `<div class="toast">${esc(msg)}</div>`;
|
||||
t.innerHTML = `<div class="toast">${esc(_tr(msg))}</div>`;
|
||||
setTimeout(() => { t.innerHTML = ''; }, 3000);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,7 @@ const I18N = {
|
||||
'Język': 'Language',
|
||||
'Konto': 'Account',
|
||||
'Szukaj…': 'Search…',
|
||||
'Szukaj… (Ctrl+K)': 'Search… (Ctrl+K)',
|
||||
'Motyw: systemowy': 'Theme: system',
|
||||
'Motyw: jasny': 'Theme: light',
|
||||
'Motyw: ciemny': 'Theme: dark',
|
||||
@@ -317,6 +318,18 @@ function localize(root) {
|
||||
_trAttr(el, 'aria-label');
|
||||
});
|
||||
}
|
||||
/* <title> lives in <head>, outside localize()'s reach, and the language button is data-no-i18n
|
||||
(its PL / EN is a code, not a word) — so their text is set here, from the Polish source. */
|
||||
const _SRC_TITLE = document.title;
|
||||
function localizeChrome() {
|
||||
document.documentElement.lang = LANG;
|
||||
const [name, sub] = _SRC_TITLE.split(' — ');
|
||||
document.title = sub ? `${name} — ${_tr(sub)}` : _tr(name);
|
||||
document.querySelectorAll('#aLang,#btnLangLogin').forEach((b) => {
|
||||
b.title = _tr('Język');
|
||||
if (b.hasAttribute('aria-label')) b.setAttribute('aria-label', b.title);
|
||||
});
|
||||
}
|
||||
function cycleLang() {
|
||||
LANG = LANG === SRC_LANG ? ALT_LANG : SRC_LANG;
|
||||
try { localStorage.setItem('panorama_lang', LANG); } catch { /* private mode */ }
|
||||
@@ -448,6 +461,7 @@ function setCrumb(parts) {
|
||||
? `<a href="${esc(p.href)}">${esc(p.label)}</a>`
|
||||
: `<b>${esc(p.label)}</b>`);
|
||||
}).join(' ');
|
||||
localize($('crumb'));
|
||||
}
|
||||
|
||||
function pageHead(title, sub, actions) {
|
||||
@@ -992,5 +1006,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
localize(document.body);
|
||||
localizeChrome();
|
||||
restore();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user