allow language dictionary to load from url or localstorage setting

This commit is contained in:
Stewart Allen 2020-03-17 10:44:42 -04:00
commit 6e25dc83b8
2 changed files with 21 additions and 6 deletions

View file

@ -1678,6 +1678,9 @@ var gs_kiri_init = exports;
}; };
API.view.set(VIEWS.ARRANGE); API.view.set(VIEWS.ARRANGE);
// show version on startup
API.show.alert(`${LANG.version} ${KIRI.version}`);
} }
// schedule init_one to run after all page content is loaded // schedule init_one to run after all page content is loaded

View file

@ -69,7 +69,7 @@ self.kiri.license = exports.LICENSE;
camStock = null, camStock = null,
camTopZ = 0, camTopZ = 0,
topZ = 0, topZ = 0,
showFavorites = SDB['dev-favorites'] === 'true', showFavorites = SDB.getItem('dev-favorites') === 'true',
alerts = []; alerts = [];
// seed defaults. will get culled on save // seed defaults. will get culled on save
@ -346,7 +346,9 @@ self.kiri.license = exports.LICENSE;
function getShowFavorites(bool) { function getShowFavorites(bool) {
if (bool !== undefined) { if (bool !== undefined) {
return SDB['dev-favorites'] = showFavorites = bool; SDB.setItem('dev-favorites', bool);
showFavorites = bool;
return bool;
} }
return showFavorites; return showFavorites;
} }
@ -1824,10 +1826,20 @@ self.kiri.license = exports.LICENSE;
} }
// allow language modules to load first // allow language modules to load first
if (SETUP.ln) KIRI.lang.set(SETUP.ln[0]);
if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]); if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]);
// show version on startup // inject language script
API.show.alert(`${LANG.version} ${KIRI.version}`); if (SETUP.ln || SDB.getItem('kiri-lang')) {
let lang = SETUP.ln ? SETUP.ln[0] : SDB.getItem('kiri-lang');
if (lang !== 'en') {
let scr = DOC.createElement('script');
scr.setAttribute('defer',true);
scr.setAttribute('src',`/kiri/lang/${lang}.js`);
DOC.body.appendChild(scr);
STATS.set('ll',lang);
scr.onload = function() {
KIRI.lang.set(lang);
}
}
}
})(); })();