mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-25 21:43:09 +02:00
Refactoring
This commit is contained in:
parent
1b0601b421
commit
3a03010ee2
1 changed files with 6 additions and 4 deletions
|
@ -69,16 +69,18 @@
|
||||||
window.lang = lang;
|
window.lang = lang;
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
let locale = localStorage.getItem('locale');
|
//#region Fetch locale data
|
||||||
|
const cachedLocale = localStorage.getItem('locale');
|
||||||
const localeKey = localStorage.getItem('localeKey');
|
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}`)
|
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}`);
|
localStorage.setItem('localeKey', `${ver}.${lang}`);
|
||||||
}
|
}
|
||||||
|
//#endregion
|
||||||
|
|
||||||
// Detect the user agent
|
// Detect the user agent
|
||||||
const ua = navigator.userAgent.toLowerCase();
|
const ua = navigator.userAgent.toLowerCase();
|
||||||
|
|
Loading…
Reference in a new issue