Skip to content

feat: complete i18n with separate translation file - #378

Open
dcox761 wants to merge 4 commits into
OpenBMB:mainfrom
bluecrystalsolutions:pr/i18n
Open

feat: complete i18n with separate translation file#378
dcox761 wants to merge 4 commits into
OpenBMB:mainfrom
bluecrystalsolutions:pr/i18n

Conversation

@dcox761

@dcox761 dcox761 commented Aug 12, 2026

Copy link
Copy Markdown

Fixes #377

There are already some English translation strings, but many are missing, especially in Advanced Options.

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.

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.
@a710128

a710128 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Great work on this refactor — one small thing: the gr.Accordion(t("advanced_accordion"), ...) on line 900 isn't bound with as so it can't be added to change_language()'s outputs, meaning the "Advanced Options" accordion title never actually switches language.

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).
@dcox761

dcox761 commented Sep 2, 2026

Copy link
Copy Markdown
Author

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 a710128 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Formalize i18n with a dedicated translation file and full English support

3 participants