EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge pull request #398 from FeiLiuEM/ui-i18n
Brandon Thomas4047ea94ea49
diff --cc crates/ui-egui/src/i18n.rsindex 47627374c,551707931..101c26144--- a/crates/ui-egui/src/i18n.rs+++ b/crates/ui-egui/src/i18n.rs@@@ -4,10 -4,14 +4,14 @@@//! plug-in names remain verbatim; these catalogs only translate the fixed menu tree.use crate::EffectcraftApp;++ /// Translations for the panels, tooltips and dialogs below the menu bar (see the module docs).+ mod ui;use effectcraft_engine::menus::MenuEntry;+ pub(crate) use ui::{set_current, tr, tr_args};/// Every language with a catalog, in the order Settings ▸ General ▸ Language lists them.-const CATALOG_CODES: [&str; 3] = ["ja", "zh-hans", "zh-hant"];+const CATALOG_CODES: [&str; 4] = ["ja", "zh-hans", "zh-hant", "uk"];/// The active interface language: the stored preference when it names a catalog, otherwise `en`/// (English is the source of every label and needs no lookup).diff --cc crates/ui-egui/src/lib.rsindex b51bb84ba,cb09da595..01a028816--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@@ -1576,16 -1573,12 +1576,17 @@@ impl eframe::App for EffectcraftAppfn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {self.apply_gpu_failure(ctx);- // The panels read the interface language from here (see `crate::i18n::ui`).- crate::i18n::set_current(crate::i18n::language(self));- if !self.styled {- theme::install(ctx, &self.tokens);- fit_window(ctx);- self.styled = true;+ // The CJK fallback fonts depend on the interface language, so they follow a change of+ // Settings ▸ General ▸ Language instead of only the first frame.+ let language = crate::i18n::language(self);++ crate::i18n::set_current(language);+ if !self.styled || self.styled_language != language {+ theme::install(ctx, &self.tokens, language);+ self.styled_language = language;+ if !self.styled {+ fit_window(ctx);+ self.styled = true;+ }ctx.request_repaint();} else {self.fonts_ready = true;diff --cc crates/ui-egui/src/panels/effect_controls.rsindex a1223b91a,194ff0cce..0d8f983b1--- a/crates/ui-egui/src/panels/effect_controls.rs+++ b/crates/ui-egui/src/panels/effect_controls.rs@@@ -996,11 -985,10 +998,11 @@@ pub fn show(app: &mut EffectcraftApp, u}}app.auto.add(&format!("effectControls.effect.{}.twirl", g.uid), tw, &g.name);- bp.text(pos2(tw.max.x + 6.0, r.center().y), Align2::LEFT_CENTER, &g.name, Tokens::semibold(12.0), t.text);+ let name = bp.text(pos2(tw.max.x + 6.0, r.center().y), Align2::LEFT_CENTER, &g.name, Tokens::semibold(12.0), t.text);+ app.auto.add(&format!("effectControls.effect.{}.name", g.uid), name, &g.name);let reset = Rect::from_min_size(pos2(r.max.x - 96.0, r.min.y + 4.0), vec2(40.0, 18.0));let rresp = ui.interact(reset, egui::Id::new(("ec-reset", g.uid)), Sense::click());- bp.text(reset.center(), Align2::CENTER_CENTER, "Reset", Tokens::ui(11.5), if rresp.hovered() { t.hot_text } else { t.text_dim });+ bp.text(reset.center(), Align2::CENTER_CENTER, crate::i18n::tr("Reset"), Tokens::ui(11.5), if rresp.hovered() { t.hot_text } else { t.text_dim });app.auto.add(&format!("effectControls.effect.{}.reset", g.uid), reset, "Reset");if rresp.clicked() {actions.push(("effect.reset".into(), json!({"layer": layer.id.0, "effect": g.uid})));diff --cc docs/preferences.mdindex f76bb15f4,a37a5f633..38ada6156--- a/docs/preferences.md+++ b/docs/preferences.md@@@ -29,7 -29,7 +29,7 @@@ Commands (CLI, MCP, control channel)### Settings that change behaviour- - `general.language`: interface language (`system` / `en` / `ja` / `zh-hans` / `zh-hant` / `uk`), Settings ▸ General ▸ Language; menu labels change immediately. `system` (Match System, the default) follows the operating system's interface language where EffectCraft has a translation and is English otherwise: a Simplified Chinese locale (`zh`, `zh-CN`, `zh_CN.UTF-8`, `zh-Hans-CN`, `zh-SG`) selects `zh-hans`, a Traditional one (`zh-TW`, `zh-HK`, `zh-Hant`, `zh_MO`) selects `zh-hant`, a Ukrainian one (`uk`, `uk-UA`, `uk_UA.UTF-8`) selects `uk`; the browser build stays in English with it. Choose **Українська** for Ukrainian menus. Dialog and panel contents retain their current English labels, as with the other menu translations. Ukrainian uses the bundled UI fonts. Native Japanese, Simplified and Traditional Chinese UI uses installed system fonts; the web host must supply a Japanese font.-- `general.language`: interface language (`system` / `en` / `ja` / `zh-hans` / `zh-hant`), Settings ▸ General ▸ Language; menu labels change immediately. `system` (Match System, the default) follows the operating system's interface language where EffectCraft has a translation and is English otherwise: a Simplified Chinese locale (`zh`, `zh-CN`, `zh_CN.UTF-8`, `zh-Hans-CN`, `zh-SG`) selects `zh-hans`, a Traditional one (`zh-TW`, `zh-HK`, `zh-Hant`, `zh_MO`) selects `zh-hant`; the browser build stays in English with it. Native Japanese, Simplified and Traditional Chinese UI uses installed system fonts; the web host must supply a Japanese font. Two catalogs back the text: the menus are keyed by `(command, English label)` (`crates/ui-egui/src/i18n.rs`), and the rest of the interface - panels, dialogs, buttons, tooltips - is keyed by its English source string (`crates/ui-egui/src/i18n/ui.rs`), where a panel writes `tr("Rename")`, or `tr_args("Proxy Use: {}", &[&quality])` when the row carries a value. A row that is missing falls back to English, so a new string shows up untranslated rather than empty; the tests in that module fail on an unused row and on a hard-coded string in a converted panel.++- `general.language`: interface language (`system` / `en` / `ja` / `zh-hans` / `zh-hant` / `uk`), Settings ▸ General ▸ Language; menu labels change immediately. `system` (Match System, the default) follows the operating system's interface language where EffectCraft has a translation and is English otherwise: a Simplified Chinese locale (`zh`, `zh-CN`, `zh_CN.UTF-8`, `zh-Hans-CN`, `zh-SG`) selects `zh-hans`, a Traditional one (`zh-TW`, `zh-HK`, `zh-Hant`, `zh_MO`) selects `zh-hant`, a Ukrainian one (`uk`, `uk-UA`, `uk_UA.UTF-8`) selects `uk`; the browser build stays in English with it. Choose **Українська** for Ukrainian menus. Ukrainian dialog and panel contents stay in English for now. Ukrainian uses the bundled UI fonts. Native Japanese, Simplified and Traditional Chinese UI uses installed system fonts; the web host must supply a Japanese font. Two catalogs back the text: the menus are keyed by `(command, English label)` (`crates/ui-egui/src/i18n.rs`), and the rest of the interface - panels, dialogs, buttons, tooltips - is keyed by its English source string (`crates/ui-egui/src/i18n/ui.rs`), where a panel writes `tr("Rename")`, or `tr_args("Proxy Use: {}", &[&quality])` when the row carries a value. A row that is missing falls back to English, so a new string shows up untranslated rather than empty; the tests in that module fail on an unused row and on a hard-coded string in a converted panel.- `general.undoLevels`: Levels of Undo- `general.pathPointSize`: Path Point and Handle Size- `general.recentItems`: Recent Projects Shown