mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-10-03 17:15:19 -07:00
fix(i18n): ensure language switch actually re-renders the tree
- `nonExplicitSupportedLngs: true` was normalizing `zh-CN` → `zh` in
some code paths; since we have explicit `zh-CN` resources, swap it
for `load: 'currentOnly'` which keeps the code as-is.
- `react: { useSuspense: false }` — react-i18next v17 defaults Suspense
on, which can silently suspend components mid-switch and look like
"nothing happens" to the user.
- Use `i18n.language` (the raw current code) instead of
`resolvedLanguage` in the selector so the dropdown always mirrors
what we just set.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
a205086733
commit
302e28e313
@@ -10,10 +10,15 @@ import { SUPPORTED_LANGUAGES } from '@/i18n';
|
|||||||
|
|
||||||
export function LanguageSelect() {
|
export function LanguageSelect() {
|
||||||
const { i18n } = useTranslation();
|
const { i18n } = useTranslation();
|
||||||
const current = SUPPORTED_LANGUAGES.find((l) => l.code === i18n.resolvedLanguage)?.code ?? 'en';
|
const current = SUPPORTED_LANGUAGES.find((l) => l.code === i18n.language)?.code ?? 'en';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select value={current} onValueChange={(value) => i18n.changeLanguage(value)}>
|
<Select
|
||||||
|
value={current}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
void i18n.changeLanguage(value);
|
||||||
|
}}
|
||||||
|
>
|
||||||
<SelectTrigger className="h-9 w-[180px]">
|
<SelectTrigger className="h-9 w-[180px]">
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
|
|||||||
@@ -21,8 +21,9 @@ i18n
|
|||||||
},
|
},
|
||||||
fallbackLng: 'en',
|
fallbackLng: 'en',
|
||||||
supportedLngs: SUPPORTED_LANGUAGES.map((l) => l.code),
|
supportedLngs: SUPPORTED_LANGUAGES.map((l) => l.code),
|
||||||
nonExplicitSupportedLngs: true,
|
load: 'currentOnly',
|
||||||
interpolation: { escapeValue: false },
|
interpolation: { escapeValue: false },
|
||||||
|
react: { useSuspense: false },
|
||||||
detection: {
|
detection: {
|
||||||
order: ['localStorage', 'navigator'],
|
order: ['localStorage', 'navigator'],
|
||||||
lookupLocalStorage: 'voicebox:lang',
|
lookupLocalStorage: 'voicebox:lang',
|
||||||
|
|||||||
Reference in New Issue
Block a user