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:
@@ -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,
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user