From f2e071baaabdb217146e11fcb6b011d92d4f8dda Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 27 Feb 2021 11:29:52 +0900 Subject: [PATCH] =?UTF-8?q?locale=E3=81=8C=E5=8F=A4=E3=81=84=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E8=87=AA=E5=8B=95=E6=9B=B4=E6=96=B0=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/web/boot.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/web/boot.js b/src/server/web/boot.js index 993b770ab1..6347c5566e 100644 --- a/src/server/web/boot.js +++ b/src/server/web/boot.js @@ -20,9 +20,10 @@ window.onerror = (e) => { const v = localStorage.getItem('v') || VERSION; //#region Detect language & fetch translations - if (localStorage.hasOwnProperty('locale')) { - // TODO: 非同期でlocaleの更新処理をする - } else { + const localeVersion = localStorage.getItem('localeVersion'); + const localeOutdated = (localeVersion == null || localeVersion !== v); + + if (!localStorage.hasOwnProperty('locale') || localeOutdated) { const supportedLangs = LANGS; let lang = localStorage.getItem('lang'); if (lang == null || !supportedLangs.includes(lang)) { @@ -39,6 +40,7 @@ window.onerror = (e) => { const res = await fetch(`/assets/locales/${lang}.${v}.json`); localStorage.setItem('lang', lang); localStorage.setItem('locale', await res.text()); + localStorage.setItem('localeVersion', v); } //#endregion