View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/692 Closes #732 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
commit
68b90df00b
8 changed files with 41 additions and 31 deletions
|
|
@ -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, langsVersion, updateLocale, locale } from '@/config.js';
|
||||
import { applyTheme } from '@/scripts/theme.js';
|
||||
import { isDeviceDarkmode } from '@/scripts/is-device-darkmode.js';
|
||||
import { updateI18n } from '@/i18n.js';
|
||||
|
|
@ -80,14 +80,15 @@ export async function common(createVue: () => App<Element>) {
|
|||
|
||||
//#region Detect language & fetch translations
|
||||
const localeVersion = miLocalStorage.getItem('localeVersion');
|
||||
const localeOutdated = (localeVersion == null || localeVersion !== version || locale == null);
|
||||
const localeOutdated = (localeVersion == null || localeVersion !== langsVersion || locale == null);
|
||||
if (localeOutdated) {
|
||||
const res = await window.fetch(`/assets/locales/${lang}.${version}.json`);
|
||||
console.info(`Updating locales from version ${localeVersion ?? 'N/A'} to ${langsVersion}`);
|
||||
const res = await window.fetch(`/assets/locales/${lang}.${langsVersion}.json`);
|
||||
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', langsVersion);
|
||||
updateLocale(parsedNewLocale);
|
||||
updateI18n(parsedNewLocale);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export const apiUrl = location.origin + '/api';
|
|||
export const wsOrigin = location.origin;
|
||||
export const lang = miLocalStorage.getItem('lang') ?? 'en-US';
|
||||
export const langs = _LANGS_;
|
||||
export const langsVersion = _LANGS_VERSION_;
|
||||
const preParseLocale = miLocalStorage.getItem('locale');
|
||||
export let locale = preParseLocale ? JSON.parse(preParseLocale) : null;
|
||||
export const version = _VERSION_;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue