feat(i18n): add Traditional Chinese (zh-TW) support with Cantonese TTS#421
Open
alvinets wants to merge 3 commits intoTHU-MAIC:mainfrom
Open
feat(i18n): add Traditional Chinese (zh-TW) support with Cantonese TTS#421alvinets wants to merge 3 commits intoTHU-MAIC:mainfrom
alvinets wants to merge 3 commits intoTHU-MAIC:mainfrom
Conversation
## Summary Add full Traditional Chinese language support including UI translations, language selector in generation toolbar, and Cantonese TTS voice mapping. ## Changes ### 1. zh-TW Language Support - Add zh-TW.json with Traditional Chinese translations (following i18n structure from PR THU-MAIC#331) - Add zh-TW entry to locales.ts with label '繁體中文' and short label 'TW' - Add language cycling in generation toolbar: zh-CN → zh-TW → en-US ### 2. Type Definitions - Update UserRequirements.language and SceneOutline.language types to include zh-TW - Add zh-TW support to generateInteractiveContent function ### 3. Cantonese TTS Voice Mapping (lib/audio/constants.ts) - Add LANGUAGE_TO_TTS_VOICE mapping for course language → TTS voice per provider - Add getVoiceForLanguage() function - Add LOCALE_TO_BROWSER_VOICE mapping: zh-TW → zh-HK (Cantonese) - Add getBrowserVoiceForLocale() function ### 4. Browser Native TTS Fixes #### Settings TTS Test (browser-tts-preview.ts) - Add locale-to-browser-TTS-language mapping (zh-TW → zh-HK) - Pass UI locale through use-tts-preview to browser TTS preview #### Discussion TTS (use-discussion-tts.ts + use-browser-tts.ts) - Add locale option to useBrowserTTS hook for language selection - Pass UI locale to browser TTS during discussion mode - Fix: resolveVoiceForAgent now properly falls back to browser-native-tts when no server TTS providers are configured (prevents 500 API errors) #### Course Playback (playback/engine.ts) - Add getCourseLanguage callback to PlaybackEngineCallbacks - Pass course language from stage to playback engine - Use course language for browser TTS: zh-TW → zh-HK, zh-CN → zh-CN, en-US → en-US ### 5. Type Updates - Add getCourseLanguage to PlaybackEngineCallbacks type (lib/playback/types.ts) - Update stage.tsx to pass course language from stage to playback engine ## Verification - TypeScript compiles successfully - All 94 tests pass ## Notes - Browser-native-tts uses 'default' voice for all agents (no per-agent gender voice) - Each agent can have custom voiceConfig set in agent settings for server TTS providers - When global TTS is set to browser-native-tts, discussion mode also uses browser TTS
wyuc
requested changes
Apr 14, 2026
Contributor
wyuc
left a comment
There was a problem hiding this comment.
The zh-TW translation looks good. Could you scope this PR down to just the UI locale support?
That would be two files:
lib/i18n/locales/zh-TW.jsonlib/i18n/locales.ts(register the new locale)
The language selector, TTS voice mapping, and browser-native-tts fixes are separate concerns and would be easier to review as individual PRs.
Also note that the toolbar language pill and toolbar.languageHint key conflict with #412, which removed manual language selection in favor of LLM inference. Worth discussing that in a separate issue.
One more thing: zh-TW → zh-HK for TTS assumes Cantonese, but Taiwan users speak Mandarin. That deserves its own discussion too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add full Traditional Chinese (zh-TW) language support including UI translations, language selector in generation toolbar, and Cantonese (zh-HK) TTS voice mapping. Also fixes browser-native-tts not playing sound during course generation and discussion mode.
Related Issues
Changes
1. zh-TW Language Support
zh-TW.jsonwith Traditional Chinese translations (following i18n structure from PR refactor(i18n): migrate to i18next framework #331)locales.tswith label '繁體中文' and short label 'TW'2. Type Definitions
UserRequirements.languageandSceneOutline.languagetypes to include zh-TWgenerateInteractiveContentfunction3. Cantonese TTS Voice Mapping (
lib/audio/constants.ts)LANGUAGE_TO_TTS_VOICEmapping for course language → TTS voice per providergetVoiceForLanguage()functionLOCALE_TO_BROWSER_VOICEmapping: zh-TW → zh-HK (Cantonese)getBrowserVoiceForLocale()function4. Browser Native TTS Fixes
getCourseLanguagecallback, pass course language from stage, use for browser TTS: zh-TW → zh-HK, zh-CN → zh-CN, en-US → en-US5. Type Updates
getCourseLanguagetoPlaybackEngineCallbackstypeType of Change
Verification
Steps to reproduce / test
What you personally verified
Evidence
pnpm check && pnpm lint && npx tsc --noEmit)Checklist