feat(i18n): Add cache versioning to prevent stale translations
All checks were successful
BotUI CI / build (push) Successful in 3m45s

- Add CACHE_VERSION constant (v1)
- Include version in cache key to auto-invalidate old caches
- Update clearCache to handle versioned keys
- Add comment explaining when to increment version
This commit is contained in:
Rodrigo Rodriguez 2026-02-14 12:09:26 +00:00
parent 4164b75c89
commit be802201fd

View file

@ -3,8 +3,12 @@
const DEFAULT_LOCALE = "en";
const STORAGE_KEY = "gb-locale";
const CACHE_VERSION = "v1";
const CACHE_TTL_MS = 3600000;
// IMPORTANT: Increment CACHE_VERSION when translation structure changes
// to invalidate all user caches and force fresh API fetches
const MINIMAL_FALLBACK = {
"label-loading": "Loading...",
"status-error": "Error",
@ -36,7 +40,7 @@
}
function getCacheKey(locale) {
return `gb-i18n-cache-${locale}`;
return `gb-i18n-cache-${locale}}-${CACHE_VERSION}`;
}
function getCachedTranslations(locale) {
@ -288,6 +292,7 @@
localStorage.removeItem(key);
}
});
console.log("i18n: Cleared all translation caches");
}
window.i18n = {