From be802201fda2c176be391115a2d4fa9ecf0c421d Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sat, 14 Feb 2026 12:09:26 +0000 Subject: [PATCH] feat(i18n): Add cache versioning to prevent stale translations - 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 --- ui/suite/js/i18n.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/suite/js/i18n.js b/ui/suite/js/i18n.js index 51960bc..5faade8 100644 --- a/ui/suite/js/i18n.js +++ b/ui/suite/js/i18n.js @@ -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 = {