Update the locale when version or language changed (#3263)

This commit is contained in:
MeiMei 2018-11-16 17:13:22 +09:00 committed by syuilo
parent 81312f5a93
commit fa66b79e2d
1 changed files with 4 additions and 1 deletions

View File

@ -69,11 +69,14 @@
//#endregion //#endregion
let locale = localStorage.getItem('locale'); let locale = localStorage.getItem('locale');
if (locale == null) { const localeKey = localStorage.getItem('localeKey');
if (locale == null || localeKey != `${ver}.${lang}`) {
const locale = await fetch(`/assets/locales/${lang}.json?ver=${ver}`) const locale = await fetch(`/assets/locales/${lang}.json?ver=${ver}`)
.then(response => response.json()); .then(response => response.json());
localStorage.setItem('locale', JSON.stringify(locale)); localStorage.setItem('locale', JSON.stringify(locale));
localStorage.setItem('localeKey', `${ver}.${lang}`);
} }
// Detect the user agent // Detect the user agent