Skip to content

i18n: Brazilian Portuguese interface language (#79) - #82

Merged
h-a-n-a-s-h-i merged 15 commits into
storytold:mainfrom
edurbs:feat/i18n-portuguese
Oct 10, 2026
Merged

h-a-n-a-s-h-i merged 15 commits into
storytold:mainfrom
edurbs:feat/i18n-portuguese

Conversation

@edurbs

@edurbs edurbs commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #79. Depends on #31 (stacked on feat/i18n-language): this branch builds on that PR's head, e8e010b — only the last commit is new. It rebases clean onto main once #31 lands.

What it adds

  • Language::PtBr — accepted as "pt" or "pt-br" (persisted/serialized as "pt"), shown as Português (Brasil) in the View ▸ Interface language switcher. A pt-BR system locale already reduces to pt, so first-run auto-detection needs no extra code.
  • PORTUGUESE table — the same 259 interface-chrome keys as the Japanese table, in the same order, using Excel's established pt-BR wording (Página Inicial, Mesclar e Centralizar, Formatação Condicional, Congelar Painéis, Preenchimento Relâmpago, Tabela Dinâmica, Classificar, Minigráficos…). A test now asserts both tables cover identical key sets and lengths, so coverage stays even as strings are added.
  • app.language.portuguese command alongside the existing ones (control channel, CLI, MCP), with the app.language.set error hint updated.
  • Like i18n: switch the interface language, defaulting to the system language (#20) #31: interface chrome only. Command ids, file names and document text stay stable; formula function names and number rendering are out of scope (cf. Feature request: Spanish-localized formula function names and separators #45).

Testing

  • cargo xtask ci — fmt, clippy, tests, assets, layers, wasm all pass.
  • Extended i18n.rs unit tests: table uniqueness/parity, pt/pt-br parsing, from_tag("pt-BR"), and app.language.portuguese switching + ui.json round-trip.
  • Offscreen snapshots rendered with --language pt (Home and View tabs) — labels fit without truncation: ribbon tabs, buttons, status bar ("Pronto"), and the switcher showing "Português (Brasil)".
  • Also adds my [people.edurbs] entry (sync_github_name = true) per the contributor-credits protocol.

justinjohn0306 and others added 5 commits October 9, 2026 10:13
A Japanese (or Chinese/Korean) workbook opened fine — the engine reads the
strings correctly — but every kanji and kana drew as a .notdef box, because
egui's bundled fonts carry no CJK coverage and nothing added a CJK face to the
fallback chain.

Append a system CJK face to every font family (UI, cell, serif, mono): a
Japanese face first for correct kana/JIS kanji, a Chinese face for breadth, and
a Hangul face for Korean. epaint picks the first face in a family that has the
glyph, so Latin still renders from the Latin fonts and only Han/Kana/Hangul
reach the CJK fonts. No font bytes are bundled (AGENTS.md): families are loaded
from the OS, and a machine with no CJK font simply keeps the old behaviour.

Tests: the CJK keys end every family chain (Latin stays first); and the
proportional family resolves 「カテゴリ」 to real glyphs, not the replacement
character — verified to fail without the fallback.
Local clippy 1.96 flags pre-existing patterns the code has always had:
manual range-contains comparisons, a dead `|| true` filter and a
simplifiable boolean. None change behaviour; they only clear the lints
so `cargo xtask ci` passes on a current toolchain.
Add an interface-language preference. It defaults to the system's
language on first run (sys-locale, native only) and is switched by hand
from the View tab, next to Dark Mode, or with app.language.english /
app.language.japanese over the control channel. It is saved in ui.json.

Follows the filmcraft house convention: a Language enum and a
table of English-to-Japanese strings with English fallback, so coverage
can grow incrementally. Japanese chrome renders without any bundled
font: the CJK fallback faces already appended to every family cover
kana and kanji.

The ribbon chrome all flows through the small_button/big_button/
toggle_button/split_button/icon_button helpers and menu_items, so
translating there localises the whole ribbon in one place; the language
of the frame is read from egui context data (i18n::current). Command
ids, file names and document text are never translated.
…sue storytold#32)

egui bundles only Latin glyphs, and the fallback chain appended just the
Han/Kana and Hangul faces, so Thai and Hebrew text rendered as tofu boxes
even though the text was read correctly.

Generalise the CJK fallback into a per-script fallback: every family now
also carries a Thai face (Leelawadee UI / Tahoma / Thonburi / Noto Sans
Thai) and a Hebrew face (David / Arial Hebrew / Noto Sans Hebrew). epaint
shapes the complex scripts itself via harfrust -- it only needed a face
that has the glyphs. The faces stay at the end of each chain, so Latin
still wins for Latin text.

The tests become script-general: a structural check that every family
ends with the loaded fallback faces, and a per-script render check that
the sample string resolves to a real glyph when the face is present.

Full bidi reordering of mixed LTR/RTL text is a separate epaint limitation
(no Unicode Bidi Algorithm); a pure other-script run is shaped correctly.
Adds PtBr to the interface-language system from storytold#31: a PORTUGUESE table
covering the same 259 chrome strings as JAPANESE (a test keeps the two
tables in step), Excel's pt-BR wording throughout, "pt"/"pt-br" codes
(serde-stored as "pt"), Português (Brasil) in the switcher, the
app.language.portuguese command, and first-run detection of a pt-BR
system locale via the existing tag reduction.
echelon and others added 9 commits October 10, 2026 12:05
- Load each fallback font file once: the region-merged Noto Sans CJK .ttc
  found for Han also covers Hangul (and Tahoma covers Thai and Hebrew), so a
  later script whose candidate file is already loaded reuses it instead of
  loading tens of MB again. New test: no two fallback faces share a file.
- Fold in the Linux CJK paths from storytold#103: Fedora google-noto-cjk/, Arch
  noto-cjk/ and wenquanyi/, Debian truetype/wqy/wqy-microhei.ttc, the SC
  .otf builds, /usr/local, plus SimSun on Windows. Document the .ttc face
  indices (JP 0, KR 1, SC 2, TC 3, HK 4); Hangul uses the KR face.
- macOS: Hiragino Sans (ヒラギノ角ゴシック W3) and Hiragino Sans GB come
  before PingFang.ttc, which recent macOS no longer ships in /System.
- Comments promise glyphs instead of tofu, not correct rendering.
- fallback_covers_its_script compared has_glyphs, which is a false negative
  when the owning face also draws the replacement glyph (DejaVu Sans as UI
  font owns Hebrew); compare laid-out glyphs with the tofu glyph instead.

Co-authored-by: eyouhi <47080137+eyouhi@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	crates/ui-egui/src/grid.rs
#	crates/ui-egui/src/ribbon.rs
#	crates/ui-egui/src/widgets.rs
…isted commands

- UiState::default() is English: tests, the kittest harness and the
  snapshot example no longer depend on the host's locale. The desktop app
  alone starts from the system language, when ui.json names no supported
  language (first run, an older file, an unknown value).
- An unknown or malformed saved language reads as English instead of
  failing the whole UiState and resetting every other preference.
- app.language.set takes {"language": "ja"} (with `code` as an alias, the
  name the PR description used); the View combo now uses it via
  Language::code(). The app.language.* commands are listed by
  engine.commands with the other UI commands and documented in
  docs/control-protocol.md.
- Home's text "Orientation" (方向) and Page Layout's print "Orientation"
  (印刷の向き) get separate keys through a `context|label` key form.
- Japanese: Hide Rows → 行を表示しない, Trace Dependents → 参照先のトレース;
  translate the display-theme combo merged in from main.
- system_theme test: the View tab now has two combo boxes; pick the theme one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…storytold#38's fallback

Merge the fixed storytold#31 branch (which carries storytold#38's font fallback) and resolve:

- theme.rs: build on storytold#38's fallback_faces/load_fallback instead of the old
  load_cjk. The interface language only reorders the two Han entries
  (sys-cjk-han-ja / sys-cjk-han-zh; Japanese first for ja, Chinese first
  otherwise); Hangul, Thai and Hebrew keep their place. The region-merged
  Noto Sans CJK .ttc is loaded once, with the leading language's face index.
- Fonts are rebuilt on a language switch only when the Han order changes
  (HanOrder), not on every switch. font_definitions()/setup_context() use
  the default order and never read the host locale.
- Tests stay locale-independent (UiState defaults to English; the desktop
  app applies the system language). The web build follows the browser
  language except CJK, which would render as tofu without system fonts.
- app.language.set error/params list all five codes; engine.commands lists
  it. zh/ko/ru gain the keys storytold#31 added (Page Layout|Orientation, display
  theme). The Page Layout screen checkbox keeps English "View" via a
  "Sheet Options|View" key (was shown as "Screen").
- Coverage test checks zh/ja/ko/Thai/Hebrew/Cyrillic in both the UI and
  cell families by comparing glyphs with the tofu glyph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… module

Merge the fixed storytold#104 branch (which carries storytold#31 and storytold#38) and restructure
the Brazilian Portuguese language onto its per-language layout:

- The PORTUGUESE table moves, unchanged, to crates/ui-egui/src/i18n/pt.rs
  as pt::translate, like zh/ko/ru. Language::PtBr gets code() "pt"
  (parse also accepts pt-BR/pt_BR via the tag reduction); it is still
  saved as "pt".
- No per-language command: the View combo and the control channel switch
  with app.language.set {"language": "pt"} (app.language.portuguese is
  dropped); error text, engine.commands params and the snapshot example
  list every code.
- pt.rs covers the keys added since (Page Layout|Orientation, the display
  theme combo, and the Sheet Options View/Print checkboxes, Exibir /
  Imprimir); the coverage test checks pt like zh/ko/ru.
- people.toml keeps both new contributor entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	crates/engine/src/cmd/file.rs
#	crates/ui-egui/src/lib.rs
#	crates/ui-egui/src/ribbon.rs
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit e72e16a into storytold:main Oct 10, 2026
@echelon

echelon commented Oct 10, 2026

Copy link
Copy Markdown
Member

Merged into main (after #104) — obrigado pelo português! Review fix-ups pushed to your branch: the table moved to i18n/pt.rs to match the per-language module structure, switching goes through the View combo and app.language.set (the separate app.language.portuguese command was dropped), and the newer keys (Sheet Options View/Print → Exibir/Imprimir, etc.) are translated.

If you haven't already, please come join us on Discord: https://discord.gg/artcraft — we'd love to have you around.

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.

Add Portuguese (pt-BR) interface translation

5 participants