feat(i18n): add Spanish (es-MX) locale support#280
feat(i18n): add Spanish (es-MX) locale support#280ellaguno wants to merge 4 commits intoTHU-MAIC:mainfrom
Conversation
Add complete Spanish (Mexican) translations for the entire UI: - All 5 i18n translation files (common, stage, chat, generation, settings) - Language selector in header with ES option - Browser language auto-detection for Spanish - Generation toolbar supports es-MX for course content language - Updated all type definitions to accept 'es-MX' locale - Updated normalizeLanguage and all language validation checks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Browser extensions (translators, Grammarly, etc.) can modify bare text
nodes in the DOM. When React tries to swap button content between a
text label and a spinner, it fails with "removeChild: node is not a
child" because the extension replaced the original text node.
Wrapping `{t(...)}` calls inside `<span>` elements gives React a
stable element reference that survives external DOM mutations.
Fixed in: provider-config-panel, pdf-settings, model-edit-dialog,
video-settings, image-settings, tts-settings.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The language selector showed 'CN' momentarily on page load because the SSR default locale is zh-CN and localStorage is only read in useEffect after mount. Now shows '...' until client hydration completes, then displays the correct locale label (CN/EN/ES). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…is resolved The server always renders with defaultLocale (zh-CN) but the client may detect a different locale from localStorage or browser language. This caused React hydration mismatches on every translated string. Fix: render children with visibility:hidden until the useEffect hydrates the correct locale from localStorage/browser, then reveal. This prevents the SSR zh-CN text from conflicting with client-side es-MX/en-US text, and also prevents browser translator extensions from intercepting the wrong-language text during the flash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey, thanks for putting this together! Since this PR was opened, we've refactored the i18n system. Adding a new locale now only needs two changes:
See the Translation Guide and #365 (Japanese) for reference. Could you rebase onto current |
1 similar comment
|
Hey, thanks for putting this together! Since this PR was opened, we've refactored the i18n system. Adding a new locale now only needs two changes:
See the Translation Guide and #365 (Japanese) for reference. Could you rebase onto current |
Summary
Closes #279
Changes
*EsMXexports with full Spanish translations (common, stage, chat, generation, settings)Localetype,VALID_LOCALES, browser detection, andgetClientTranslation'zh-CN' | 'en-US'unions to include'es-MX', updatednormalizeLanguage()Test plan
es-*→ app should auto-detect and default to Spanishnpx tsc --noEmit— passes with 0 errorspnpm lint— 0 new errors (only pre-existing warnings)🤖 AI-assisted with Claude Code — reviewed by @ellaguno