feat(i18n): Add cache versioning to prevent stale translations
All checks were successful
BotUI CI / build (push) Successful in 3m45s
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:
parent
4164b75c89
commit
be802201fd
1 changed files with 6 additions and 1 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue