mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-25 02:09:05 +01:00
Merge pull request 'Delete empty locale files & Fetch locales regardless of version' (#9223) from CherryKitten/calckey:develop into develop
Reviewed-on: https://codeberg.org/thatonecalculator/calckey/pulls/9223
This commit is contained in:
commit
1103d08332
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -1 +0,0 @@
|
|||||||
---
|
|
@ -22,37 +22,32 @@
|
|||||||
renderError('SOMETHING_HAPPENED_IN_PROMISE', e);
|
renderError('SOMETHING_HAPPENED_IN_PROMISE', e);
|
||||||
};
|
};
|
||||||
|
|
||||||
const v = localStorage.getItem('v') || VERSION;
|
|
||||||
|
|
||||||
//#region Detect language & fetch translations
|
//#region Detect language & fetch translations
|
||||||
const localeVersion = localStorage.getItem('localeVersion');
|
const v = localStorage.getItem('v') || VERSION;
|
||||||
const localeOutdated = (localeVersion == null || localeVersion !== v);
|
|
||||||
|
const supportedLangs = LANGS;
|
||||||
if (!localStorage.hasOwnProperty('locale') || localeOutdated) {
|
let lang = localStorage.getItem('lang');
|
||||||
const supportedLangs = LANGS;
|
if (lang == null || !supportedLangs.includes(lang)) {
|
||||||
let lang = localStorage.getItem('lang');
|
if (supportedLangs.includes(navigator.language)) {
|
||||||
if (lang == null || !supportedLangs.includes(lang)) {
|
lang = navigator.language;
|
||||||
if (supportedLangs.includes(navigator.language)) {
|
|
||||||
lang = navigator.language;
|
|
||||||
} else {
|
|
||||||
lang = supportedLangs.find(x => x.split('-')[0] === navigator.language);
|
|
||||||
|
|
||||||
// Fallback
|
|
||||||
if (lang == null) lang = 'en-US';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await fetch(`/assets/locales/${lang}.${v}.json`);
|
|
||||||
if (res.status === 200) {
|
|
||||||
localStorage.setItem('lang', lang);
|
|
||||||
localStorage.setItem('locale', await res.text());
|
|
||||||
localStorage.setItem('localeVersion', v);
|
|
||||||
} else {
|
} else {
|
||||||
await checkUpdate();
|
lang = supportedLangs.find(x => x.split('-')[0] === navigator.language);
|
||||||
renderError('LOCALE_FETCH');
|
|
||||||
return;
|
// Fallback
|
||||||
|
if (lang == null) lang = 'en-US';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const res = await fetch(`/assets/locales/${lang}.${v}.json`);
|
||||||
|
if (res.status === 200) {
|
||||||
|
localStorage.setItem('lang', lang);
|
||||||
|
localStorage.setItem('locale', await res.text());
|
||||||
|
localStorage.setItem('localeVersion', v);
|
||||||
|
} else {
|
||||||
|
await checkUpdate();
|
||||||
|
renderError('LOCALE_FETCH');
|
||||||
|
return;
|
||||||
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
//#region Script
|
//#region Script
|
||||||
|
Loading…
Reference in New Issue
Block a user