fix(i18n): Add comprehensive cache and fetch logging
All checks were successful
BotUI CI / build (push) Successful in 4m13s
All checks were successful
BotUI CI / build (push) Successful in 4m13s
This commit is contained in:
parent
2bb7959666
commit
4164b75c89
1 changed files with 7 additions and 1 deletions
|
|
@ -44,7 +44,9 @@
|
|||
const cached = localStorage.getItem(getCacheKey(locale));
|
||||
if (cached) {
|
||||
const { data, timestamp } = JSON.parse(cached);
|
||||
if (Date.now() - timestamp < CACHE_TTL_MS) {
|
||||
const age = Date.now() - timestamp;
|
||||
console.log(`i18n: Cache check for ${locale}: age=${Math.round(age/1000)}s, valid=${age < CACHE_TTL_MS}, keys=${Object.keys(data || {}).length}`);
|
||||
if (age < CACHE_TTL_MS) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
@ -89,13 +91,16 @@
|
|||
}
|
||||
|
||||
async function loadTranslations(locale) {
|
||||
console.log(`i18n: loadTranslations called for locale: ${locale}`);
|
||||
const cached = getCachedTranslations(locale);
|
||||
if (cached) {
|
||||
console.log(`i18n: Using cached translations for ${locale}`);
|
||||
translations = cached;
|
||||
currentLocale = locale;
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log(`i18n: Cache miss, fetching from API for ${locale}`);
|
||||
const fetched = await fetchTranslations(locale);
|
||||
if (fetched && Object.keys(fetched).length > 0) {
|
||||
translations = fetched;
|
||||
|
|
@ -109,6 +114,7 @@
|
|||
return loadTranslations(DEFAULT_LOCALE);
|
||||
}
|
||||
|
||||
console.warn(`i18n: No translations found, using minimal fallback`);
|
||||
translations = MINIMAL_FALLBACK;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue