refactor(i18n): lazy-load per-language files on demand

This commit is contained in:
SirMcPotato
2026-04-07 02:43:37 +02:00
parent 6f63a10609
commit 35d02e74f6
9 changed files with 1067 additions and 1380 deletions
+12 -8
View File
@@ -281,10 +281,10 @@ setViewerTheme(document.documentElement.getAttribute('data-theme') === 'light');
function populateLanguageSelector() {
if (!languageSelector) return;
languageSelector.innerHTML = '';
const select = document.createElement('select');
select.className = 'lang-dropdown';
for (const langKey in TRANSLATIONS) {
const opt = document.createElement('option');
opt.value = langKey;
@@ -292,17 +292,21 @@ function populateLanguageSelector() {
opt.textContent = TRANSLATIONS[langKey]['lang.name'] || langKey.toUpperCase();
select.appendChild(opt);
}
select.addEventListener('change', (e) => {
setLang(e.target.value);
select.addEventListener('change', async (e) => {
await setLang(e.target.value);
// Re-translate <option> elements (innerHTML won't reach these)
document.querySelectorAll('select[id="mapping-mode"] option[data-i18n-opt]').forEach(opt => {
document.querySelectorAll('#mapping-mode option[data-i18n-opt]').forEach(opt => {
opt.textContent = t(opt.dataset.i18nOpt);
});
// Refresh dynamic count text to current language
if (currentGeometry) refreshExclusionOverlay();
if (currentGeometry) {
refreshExclusionOverlay();
}
});
languageSelector.appendChild(select);
}
populateLanguageSelector();