Skip to content

Developer I18n

github-actions[bot] edited this page May 22, 2026 · 2 revisions

Internationalization

BLXCode keeps UI strings and EULA content in explicit locale sources so translations are checked at compile time.

Important Files

  • src/i18n/keys.rs: I18nKey enum.
  • src/i18n/locale.rs: locale metadata and parsing.
  • src/i18n/locales/en_us.rs: English source strings.
  • src/i18n/locales/*.rs: translated locale tables.
  • src/i18n/eula.rs: compiled EULA markdown lookup.
  • content/eula/*.md: localized EULA markdown.
  • scripts/tools/render_i18n_locales_from_en.py: helper script for rendering non-English tables from English.

Adding A UI String

  1. Add a new variant to I18nKey.
  2. Add the English string to src/i18n/locales/en_us.rs.
  3. Add the translated string to every other locale file.
  4. Use i18n.tr(I18nKey::YourKey)() from Leptos views.
  5. Run a frontend check.

Appearance theme strings use paired keys per catalog id (ThemeNameBlxcodeDark, ThemeDescBlxcodeDark, …) wired through src/theme/i18n.rs. UI chrome keys (AppearanceHeroTitle, AppearanceFilterDark, …) live beside other settings strings in en_us.rs.

cargo check -p blxcode-ui --target wasm32-unknown-unknown

The locale match tables are intentionally exhaustive. Missing strings should fail compilation instead of silently falling back.

Regenerating Locale Tables

The helper script fills non-English locale files from en_us.rs. It requires deep-translator in a Python environment.

Default (safe): only translates I18nKey rows that are missing from a locale file (new keys you added to en_us.rs).

python scripts/tools/render_i18n_locales_from_en.py

Specific keys only:

python scripts/tools/render_i18n_locales_from_en.py --keys GitignorePromptTitle,GitignorePromptBody

Also replace rows that still match English verbatim (use sparingly — can re-translate many rows):

python scripts/tools/render_i18n_locales_from_en.py --patch-english-matches

Parallel workers (-j N runs up to N concurrent translate requests per locale, with shared rate limiting):

python scripts/tools/render_i18n_locales_from_en.py --patch-english-matches -j 4

Full rewrite (every string in every locale — slow, overwrites good translations):

python scripts/tools/render_i18n_locales_from_en.py --full

Machine translation should be reviewed before release.

EULA Content

EULA content is Markdown under content/eula/. The frontend compiles these files through include_str! in src/i18n/eula.rs.

When adding a new locale, add both:

  • A locale enum/metadata entry.
  • A matching EULA Markdown file.

Locale Storage

The selected UI locale is stored in local storage under blxcode_locale_v1.

EULA acceptance is stored under blxcode_eula_v2. Bump that key when materially changing content/eula/*.md so existing installs see the updated terms.

Clone this wiki locally