localeが古い場合自動更新するように
This commit is contained in:
parent
34fef37e54
commit
f2e071baaa
@ -20,9 +20,10 @@ window.onerror = (e) => {
|
|||||||
const v = localStorage.getItem('v') || VERSION;
|
const v = localStorage.getItem('v') || VERSION;
|
||||||
|
|
||||||
//#region Detect language & fetch translations
|
//#region Detect language & fetch translations
|
||||||
if (localStorage.hasOwnProperty('locale')) {
|
const localeVersion = localStorage.getItem('localeVersion');
|
||||||
// TODO: 非同期でlocaleの更新処理をする
|
const localeOutdated = (localeVersion == null || localeVersion !== v);
|
||||||
} else {
|
|
||||||
|
if (!localStorage.hasOwnProperty('locale') || localeOutdated) {
|
||||||
const supportedLangs = LANGS;
|
const supportedLangs = LANGS;
|
||||||
let lang = localStorage.getItem('lang');
|
let lang = localStorage.getItem('lang');
|
||||||
if (lang == null || !supportedLangs.includes(lang)) {
|
if (lang == null || !supportedLangs.includes(lang)) {
|
||||||
@ -39,6 +40,7 @@ window.onerror = (e) => {
|
|||||||
const res = await fetch(`/assets/locales/${lang}.${v}.json`);
|
const res = await fetch(`/assets/locales/${lang}.${v}.json`);
|
||||||
localStorage.setItem('lang', lang);
|
localStorage.setItem('lang', lang);
|
||||||
localStorage.setItem('locale', await res.text());
|
localStorage.setItem('locale', await res.text());
|
||||||
|
localStorage.setItem('localeVersion', v);
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user