mirror of
https://github.com/CNCKitchen/stlTexturizer.git
synced 2026-04-07 22:11:32 +00:00
refactor(i18n): lazy-load per-language files on demand
This commit is contained in:
+12
-8
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user