fix(i18n): Add logging to debug translation loading
All checks were successful
BotUI CI / build (push) Successful in 5m12s

This commit is contained in:
Rodrigo Rodriguez 2026-02-14 11:54:08 +00:00
parent b68fc0aa85
commit 2bb7959666

View file

@ -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", () => {