v0.13.8
This commit is contained in:
+2
-7
@@ -265,19 +265,14 @@ function renderLanguageOptions() {
|
||||
|
||||
async function loadLanguages() {
|
||||
try {
|
||||
const languageNonce = Date.now().toString(36);
|
||||
const languageUrl = path => {
|
||||
const separator = String(path).includes('?') ? '&' : '?';
|
||||
return `${withBase(path)}${separator}v=${languageNonce}`;
|
||||
};
|
||||
const response = await fetch(languageUrl('/lang/index.json'), { cache: 'no-store' });
|
||||
const response = await fetch(withBase('/lang/index.json'));
|
||||
if (!response.ok) throw new Error(`Language index HTTP ${response.status}`);
|
||||
const manifest = await response.json();
|
||||
const languages = Array.isArray(manifest.languages) ? manifest.languages : [];
|
||||
if (!languages.some(item => item.code === DEFAULT_LANGUAGE)) throw new Error('Default English language pack is missing');
|
||||
|
||||
const loaded = await Promise.all(languages.map(async item => {
|
||||
const packResponse = await fetch(languageUrl(item.path || `/lang/${encodeURIComponent(item.code)}.json`), { cache: 'no-store' });
|
||||
const packResponse = await fetch(withBase(item.path || `/lang/${encodeURIComponent(item.code)}.json`));
|
||||
if (!packResponse.ok) throw new Error(`Language ${item.code} HTTP ${packResponse.status}`);
|
||||
const pack = await packResponse.json();
|
||||
return { item, pack };
|
||||
|
||||
+8
-4
@@ -4,10 +4,14 @@ window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', ()
|
||||
if ('serviceWorker' in navigator) window.addEventListener('load', () => navigator.serviceWorker.register(withBase('/sw.js')).catch(() => { }));
|
||||
|
||||
async function startApplication() {
|
||||
observeTopbarHeight();
|
||||
applyTheme();
|
||||
await loadLanguages();
|
||||
applyTranslations();
|
||||
try {
|
||||
observeTopbarHeight();
|
||||
applyTheme();
|
||||
await loadLanguages();
|
||||
applyTranslations();
|
||||
} finally {
|
||||
document.documentElement.classList.remove('i18n-loading');
|
||||
}
|
||||
setupFormUx();
|
||||
updateZoneSensorFields();
|
||||
updateSchedulePresetField();
|
||||
|
||||
Reference in New Issue
Block a user