text, ui: follow a language change, and resolve the language before the fonts

Review follow-ups on #312:

- `crates/ui-egui/src/theme.rs`'s `japanese_font_tests` still called `install` with two
  arguments, so `cargo test` did not compile. Every call site now passes a language.
- The call sites passed the stored `general.language` preference. With the default `system`
  that is `""`, which handed the CJK choice back to the environment locale — one macOS and
  Windows usually do not set. They now pass `crate::i18n::language(app)`, the resolved
  language, so Match System draws Chinese on a Chinese system.
- Changing Settings ▸ General ▸ Language only reached the fonts on the first frame.
  `EffectcraftApp` now remembers the language its fonts were installed for and installs them
  again when it changes, so the switch applies without a restart.
- Documented that `fonts::set_cjk_locale` is process-global: the Han preference therefore
  applies to composition text as well as the interface chrome (docs/preferences.md and the
  function's own comment).

Rebased onto main after #309 landed — `header.rs` gained an `install` call site in the
meantime, and the catalogs now resolve through `i18n::language`.
This commit is contained in:
FeiLiuEM
2026-10-09 19:28:42 +08:00
parent a4d1e8d0b3
commit ad3da3c8de
11 changed files with 32 additions and 19 deletions
+1 -1
View File
@@ -2244,7 +2244,7 @@ mod tests {
let mut app = EffectcraftApp::new(effectcraft_engine::Session::default());
let ctx = egui::Context::default();
let tokens = crate::theme::Tokens::for_kind(crate::theme::ThemeKind::Dark);
crate::theme::install(&ctx, &tokens, &app.session.prefs.general.language);
crate::theme::install(&ctx, &tokens, language(app));
crate::panels::settings::open(&mut app, "general");
let mut out = ctx.run_ui(egui::RawInput::default(), |_| {
crate::panels::settings::show(&mut app, &ctx, &tokens);