Refactoring

This commit is contained in:
syuilo 2019-02-01 00:09:28 +09:00
parent 1b0601b421
commit 3a03010ee2
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -69,16 +69,18 @@
window.lang = lang;
//#endregion
let locale = localStorage.getItem('locale');
//#region Fetch locale data
const cachedLocale = localStorage.getItem('locale');
const localeKey = localStorage.getItem('localeKey');
if (locale == null || localeKey != `${ver}.${lang}`) {
if (cachedLocale == null || localeKey != `${ver}.${lang}`) {
const locale = await fetch(`/assets/locales/${lang}.json?ver=${ver}`)
.then(response => response.json());
localStorage.setItem('locale', JSON.stringify(locale));
localStorage.setItem('localeKey', `${ver}.${lang}`);
}
//#endregion
// Detect the user agent
const ua = navigator.userAgent.toLowerCase();