From af7fb2bc15468cc6cb9dc7103305e63c5a2c388e Mon Sep 17 00:00:00 2001 From: Massedil Date: Mon, 16 Jun 2025 16:44:01 +0200 Subject: [PATCH] fix: components not updating correctly when changing language /2 Fixes : - lacking i18n.global.locale.value in datetime.ts - remove a test in i18n.ts that was always false in past versions of the code because i18n.global.locale is an object and lang is a string - correctly type createI18n with for legacy to solve wrong TypeScript error (see https://github.com/intlify/vue-i18n/issues/785, https://github.com/intlify/vue-i18n/issues/889#issuecomment-1017250573) Fixes: #1597, #1772, and possibly other related issues. --- src/filters/datetime.ts | 2 +- src/utils/i18n.ts | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/filters/datetime.ts b/src/filters/datetime.ts index c1f812739..b9e0cebcb 100644 --- a/src/filters/datetime.ts +++ b/src/filters/datetime.ts @@ -79,7 +79,7 @@ function formatDateTimeString( return format.format(parseDateTime(value)); } -const locale = () => i18n.global.locale.replace("_", "-"); +const locale = () => i18n.global.locale.value.replace("_", "-"); export { formatDateISOStringWithoutTime, diff --git a/src/utils/i18n.ts b/src/utils/i18n.ts index bae4287ee..e7641008e 100644 --- a/src/utils/i18n.ts +++ b/src/utils/i18n.ts @@ -26,7 +26,7 @@ export const locale = ? language : language.split("-")[0]; -export const i18n = createI18n({ +export const i18n = createI18n({ legacy: false, locale: locale, // set locale // eslint-disable-next-line @typescript-eslint/ban-ts-comment @@ -77,11 +77,6 @@ function vueI18NfileForLanguage(lang: string) { } export async function loadLanguageAsync(lang: string): Promise { - // If the same language - if (i18n.global.locale === lang) { - return Promise.resolve(setI18nLanguage(lang)); - } - // If the language was already loaded if (loadedLanguages.includes(lang)) { return Promise.resolve(setI18nLanguage(lang));