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:
James Pine
2026-04-20 02:52:08 -07:00
co-authored by Claude Opus 4.7
parent a205086733
commit 302e28e313
2 changed files with 9 additions and 3 deletions
@@ -10,10 +10,15 @@ import { SUPPORTED_LANGUAGES } from '@/i18n';
export function LanguageSelect() {
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 (
<Select value={current} onValueChange={(value) => i18n.changeLanguage(value)}>
<Select
value={current}
onValueChange={(value) => {
void i18n.changeLanguage(value);
}}
>
<SelectTrigger className="h-9 w-[180px]">
<SelectValue />
</SelectTrigger>
+2 -1
View File
@@ -21,8 +21,9 @@ i18n
},
fallbackLng: 'en',
supportedLngs: SUPPORTED_LANGUAGES.map((l) => l.code),
nonExplicitSupportedLngs: true,
load: 'currentOnly',
interpolation: { escapeValue: false },
react: { useSuspense: false },
detection: {
order: ['localStorage', 'navigator'],
lookupLocalStorage: 'voicebox:lang',