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' |