fix(i18n): add cache-busting to translation fetches
Forces fresh translation fetches on every language change by appending ?v=<timestamp> to bypass browser cache and service worker cache. Resolves production cache issues where stale translation files persisted after service worker updates. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
97691e3ef4
commit
ab05190e5e
1 changed files with 5 additions and 2 deletions
|
|
@ -92,8 +92,11 @@ const I18n = {
|
|||
|
||||
async loadTranslations(lang) {
|
||||
try {
|
||||
// Cache-busting: Add timestamp to force fresh fetch and bypass stale cache
|
||||
const cacheBust = `?v=${Date.now()}`;
|
||||
|
||||
// Always load common translations (footer, navbar, etc.)
|
||||
const commonResponse = await fetch(`/locales/${lang}/common.json`);
|
||||
const commonResponse = await fetch(`/locales/${lang}/common.json${cacheBust}`);
|
||||
let commonTranslations = {};
|
||||
if (commonResponse.ok) {
|
||||
commonTranslations = await commonResponse.json();
|
||||
|
|
@ -101,7 +104,7 @@ const I18n = {
|
|||
|
||||
// Load page-specific translations
|
||||
const pageName = this.detectPageName();
|
||||
const pageResponse = await fetch(`/locales/${lang}/${pageName}.json`);
|
||||
const pageResponse = await fetch(`/locales/${lang}/${pageName}.json${cacheBust}`);
|
||||
let pageTranslations = {};
|
||||
if (pageResponse.ok) {
|
||||
pageTranslations = await pageResponse.json();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue