fix(i18n): Add logging to debug translation loading
All checks were successful
BotUI CI / build (push) Successful in 5m12s
All checks were successful
BotUI CI / build (push) Successful in 5m12s
This commit is contained in:
parent
b68fc0aa85
commit
2bb7959666
1 changed files with 7 additions and 1 deletions
|
|
@ -70,6 +70,7 @@
|
||||||
|
|
||||||
async function fetchTranslations(locale) {
|
async function fetchTranslations(locale) {
|
||||||
try {
|
try {
|
||||||
|
console.log(`i18n: Fetching translations for locale: ${locale}`);
|
||||||
const response = await fetch(`/api/i18n/${locale}`, {
|
const response = await fetch(`/api/i18n/${locale}`, {
|
||||||
headers: { Accept: "application/json" },
|
headers: { Accept: "application/json" },
|
||||||
});
|
});
|
||||||
|
|
@ -79,9 +80,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
console.log(`i18n: Loaded ${Object.keys(result.translations || {}).length} translations for ${locale}`);
|
||||||
return result.translations || {};
|
return result.translations || {};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(`i18n: Failed to fetch translations for ${locale}`, e);
|
console.error(`i18n: Failed to fetch translations for ${locale}`, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,14 +234,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
console.log("i18n: Initialization started");
|
||||||
if (isInitialized) {
|
if (isInitialized) {
|
||||||
|
console.log("i18n: Already initialized, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const locale = detectBrowserLocale();
|
const locale = detectBrowserLocale();
|
||||||
|
console.log(`i18n: Detected locale: ${locale}`);
|
||||||
await loadTranslations(locale);
|
await loadTranslations(locale);
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
|
console.log(`i18n: Initialization complete, current locale: ${currentLocale}`);
|
||||||
|
|
||||||
if (document.readyState === "loading") {
|
if (document.readyState === "loading") {
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue