fix: components not updating correctly when changing language
The issue was caused by incorrect handling of the `i18n.global.locale` value in the Composition API.
When using `createI18n` with `legacy: false`, `i18n.global.locale` is a reactive ref.
Assigning directly with `i18n.global.locale = lang;` breaks reactivity.
The correct usage is : `i18n.global.locale.value = lang;`.
However, this assignment was unnecessary because the value is already updated automatically when the language changes.
All scripts using `const { locale } = useI18n({ useScope: "global" });` are updated to use `locale.value` instead of just `locale`, to ensure correct reactive behavior.
Fixes: #1597, #1772, and possibly other related issues.
This commit is contained in:
@@ -23,10 +23,10 @@ const { locale } = useI18n({ useScope: "global" });
|
||||
const { result: configResult } = useQuery<{ config: IConfig }>(
|
||||
PRIVACY,
|
||||
() => ({
|
||||
locale: locale,
|
||||
locale: locale.value,
|
||||
}),
|
||||
() => ({
|
||||
enabled: locale !== undefined,
|
||||
enabled: locale.value !== undefined,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ const { result: termsResult, loading: termsLoading } = useQuery<{
|
||||
}>(
|
||||
TERMS,
|
||||
() => ({
|
||||
locale: locale,
|
||||
locale: locale.value,
|
||||
}),
|
||||
() => ({
|
||||
enabled: locale !== undefined,
|
||||
enabled: locale.value !== undefined,
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user