diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts index 2e62383eb0a5..db19d9f02b60 100644 --- a/packages/frontend/src/boot/common.ts +++ b/packages/frontend/src/boot/common.ts @@ -8,7 +8,7 @@ import { compareVersions } from 'compare-versions'; import widgets from '@/widgets/index.js'; import directives from '@/directives/index.js'; import components from '@/components/index.js'; -import { version, lang, updateLocale, locale } from '@/config.js'; +import { version, lang, updateLocale, locale, commitHash } from '@/config.js'; import { applyTheme } from '@/scripts/theme.js'; import { isDeviceDarkmode } from '@/scripts/is-device-darkmode.js'; import { updateI18n } from '@/i18n.js'; @@ -81,15 +81,16 @@ export async function common(createVue: () => App) { //#endregion //#region Detect language & fetch translations - const localeVersion = miLocalStorage.getItem('localeVersion'); - const localeOutdated = (localeVersion == null || localeVersion !== version || locale == null); + const revision = commitHash ?? 'unknown'; + const newLocaleVersion = `${version}+REV:${revision}`; + const localeOutdated = miLocalStorage.getItem('localeVersion') !== newLocaleVersion || locale == null; if (localeOutdated) { - const res = await window.fetch(`/assets/locales/${lang}.${version}.json`); + const res = await window.fetch(`/assets/locales/${lang}.${version}.json?rev=${revision}`); if (res.status === 200) { const newLocale = await res.text(); const parsedNewLocale = JSON.parse(newLocale); miLocalStorage.setItem('locale', newLocale); - miLocalStorage.setItem('localeVersion', version); + miLocalStorage.setItem('localeVersion', newLocaleVersion); updateLocale(parsedNewLocale); updateI18n(parsedNewLocale); } diff --git a/packages/frontend/src/pages/tms/flags/index.main.vue b/packages/frontend/src/pages/tms/flags/index.main.vue index fa1b09172df1..3fd6336ec90f 100644 --- a/packages/frontend/src/pages/tms/flags/index.main.vue +++ b/packages/frontend/src/pages/tms/flags/index.main.vue @@ -31,7 +31,7 @@ import { defineAsyncComponent, readonly, ref, watch } from 'vue'; import { commitHash, lang, version } from '@/config.js'; import { i18n } from '@/i18n.js'; import { miLocalStorage } from '@/local-storage.js'; -import { confirm, inputText, popup, waiting } from '@/os.js'; +import { confirm, popup, waiting } from '@/os.js'; import FormSection from '@/components/form/section.vue'; import MkButton from '@/components/MkButton.vue'; import MkFolder from '@/components/MkFolder.vue'; @@ -47,22 +47,15 @@ const confirmDialog = async (): Promise => { }; const forceFetchLocale = async (): Promise => { - const defaultValue = commitHash ?? Date.now().toString(); - const { canceled, result } = await inputText({ - type: 'text', - text: 'Revision?', - placeholder: defaultValue, - default: defaultValue, - }); - if (canceled) return; if (!(await confirmDialog())) return; waiting(); - const revision = result || defaultValue; - const res = await window.fetch(`/assets/locales/${lang}.${version}.json?rev=${revision}`); + const revision = commitHash ?? 'unknown'; + const newLocaleVersion = `${version}+REV:${revision}`; + const res = await window.fetch(`/assets/locales/${lang}.${version}.json?date=${Date.now().toString()}`); if (res.status === 200) { const newLocale = await res.text(); miLocalStorage.setItem('locale', newLocale); - miLocalStorage.setItem('localeVersion', version); + miLocalStorage.setItem('localeVersion', newLocaleVersion); } location.reload(); };