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 <false> 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.
This commit is contained in:
Massedil
2025-06-16 16:44:01 +02:00
parent f9f31f9f53
commit af7fb2bc15
2 changed files with 2 additions and 7 deletions

View File

@@ -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,

View File

@@ -26,7 +26,7 @@ export const locale =
? language
: language.split("-")[0];
export const i18n = createI18n({
export const i18n = createI18n<false>({
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<string> {
// 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));