feat: complete i18n with separate translation file - #378
Conversation
Refactor localization into a clean architecture:
- i18n.py: single source of truth for all UI strings (zh + en)
- t() helper for simple string lookup
- VOXCPM_LANG env var controls default language
All widget creation uses t('key'), change_language() uses
STRINGS[lang]['key']. No ternaries, no duplicate dicts, no if/else
for language selection.
Chinese strings verified against original source — zero changes.
|
Great work on this refactor — one small thing: the |
The gr.Accordion on the Advanced Options section was not captured with 'as advanced_acc', so it could not be included in change_language()'s outputs list. The accordion title never switched when the user changed language. - Add 'as advanced_acc' to the Accordion context manager - Add gr.update(label=d['advanced_accordion']) to the return tuple - Add advanced_acc to the outputs list
These were untranslated in the original upstream source — warmup_steps was bare snake_case and dropout was English-only. Now follows the established pattern: '中文翻译 (english_term)'. - warmup_steps: warmup_steps → 预热步数 (warmup_steps) - dropout: LoRA Dropout → LoRA 丢弃率 (Dropout)
Runtime strings (print to stderr + error return values) were hardcoded Chinese, making them unreadable when VOXCPM_LANG=en. Now uses t() with .format() for all 5 runtime strings: - log_ref_audio_no_text: ASR auto-recognition starting - log_auto_recognized: ASR result - error_asr_failed: ASR returned empty (shown in UI status) - error_asr_exception: ASR exception (shown in UI status) - log_refresh_lora: LoRA checkpoint scan count Also restores Chinese code comments to match upstream convention (comments are developer-facing, not user-facing).
|
Thank you for reviewing. I have fixed the accordion and added two missing Chinese strings (I hope the translation is correct). I also went too far removing Chinese comments in the code - reverted, but also fixed some error and print output. |
a710128
left a comment
There was a problem hiding this comment.
Thanks for the quick fix! Verified in a real browser — the Advanced Options accordion now switches language immediately, and all 56 outputs in change_language() are correctly bound (checked via the Blocks config graph). Note: the inactive Inference tab label doesn't repaint until you click into it, but that's a Gradio rendering quirk for hidden tabs, not something this PR needs to fix. LGTM 🚀
Fixes #377
There are already some English translation strings, but many are missing, especially in Advanced Options.
Refactor localization into a clean architecture:
All widget creation uses t('key'), change_language() uses STRINGS[lang]['key']. No ternaries, no duplicate dicts, no if/else for language selection.
Chinese strings verified against original source — zero changes.