From bd469420fa6554db0caff17406f356761dbe1f00 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 21 Jan 2023 20:24:15 +0900 Subject: [PATCH] =?UTF-8?q?fix(client):=20=E3=82=AF=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=82=A2=E3=83=B3=E3=83=88=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=AB?= =?UTF-8?q?=E3=82=82=E8=A8=80=E8=AA=9E=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=AE=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=82=92=E8=A1=8C?= =?UTF-8?q?=E3=81=86=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #9005 --- packages/frontend/src/init.ts | 13 +++++++++++++ packages/frontend/src/local-storage.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/packages/frontend/src/init.ts b/packages/frontend/src/init.ts index 09fb7caf14..d90d3b5532 100644 --- a/packages/frontend/src/init.ts +++ b/packages/frontend/src/init.ts @@ -80,6 +80,19 @@ import { claimAchievement, claimedAchievements } from './scripts/achievements'; }); } + //#region Detect language & fetch translations + const localeVersion = miLocalStorage.getItem('localeVersion'); + const localeOutdated = (localeVersion == null || localeVersion !== version); + if (localeOutdated) { + const res = await window.fetch(`/assets/locales/${lang}.${version}.json`); + if (res.status === 200) { + miLocalStorage.setItem('locale', await res.text()); + miLocalStorage.setItem('localeVersion', version); + location.reload(); + } + } + //#endregion + // タッチデバイスでCSSの:hoverを機能させる document.addEventListener('touchend', () => {}, { passive: true }); diff --git a/packages/frontend/src/local-storage.ts b/packages/frontend/src/local-storage.ts index bb8192e980..68dc9ebe41 100644 --- a/packages/frontend/src/local-storage.ts +++ b/packages/frontend/src/local-storage.ts @@ -19,6 +19,7 @@ type Keys = 'fontSize' | 'ui' | 'locale' | + 'localeVersion' | 'theme' | 'customCss' | 'message_drafts' |