FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust
i18n: Japanese interface language using an installed system font
midasdfbab130c358c3
diff --git a/ROADMAP.md b/ROADMAP.mdindex a65de3fa5..3face4e1a 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -200,3 +200,7 @@ Status: ✅ done · 🟡 in progress · ⬜ not started. Estimates are remaining- **2026-09-30 (midday):** HEVC decoder, Matroska/WebM demuxer and audio DSP merged; HEVC import wired; asset rules (AGENTS.md, ATTRIBUTION.md, `cargo xtask assets`); README with hero screenshot and the Craft family.- **2026-09-30 (late morning):** keyframe value/velocity graphs; xtask gates; H.264 MP4 export; Lumetri curves, wheels, looks, HSL secondary.- **2026-09-30 (early morning):** H.264 decoder, ProRes, AAC; GPU compositor; MCP; Premiere 26 visual fidelity pass.++### Interface localization++Edit > Language switches English/Japanese and persists in UI state. Commands `app.language.english` and `app.language.japanese` are reachable through the control channel. Core native/in-window menu labels are translated; untranslated labels use English. Japanese text uses a Japanese font already installed on the system (none is bundled); without one, switching to Japanese is refused with a message. Dialog/panel translation coverage remains open. Existing vertical text support is preserved.diff --git a/apps/filmcraft/src/native_menu.rs b/apps/filmcraft/src/native_menu.rsindex be15f6ecc..52d31f786 100644--- a/apps/filmcraft/src/native_menu.rs+++ b/apps/filmcraft/src/native_menu.rs@@ -25,10 +25,12 @@ pub type ShortcutUpdater = Box<dyn FnMut(&[Item])>;pub fn install(app: &FilmcraftApp, ctx: egui::Context) -> (Receiver<String>, ShortcutUpdater) {let items = menu_items(app);let mut native: Vec<(String, MenuItem)> = Vec::new();+ let mut titles: Vec<(String, Submenu)> = Vec::new();let bar = Menu::new();let app_menu = Submenu::new("FilmCraft", true);// FilmCraft ▸ Settings ▸ <category> (Premiere's app-menu layout; General is Cmd+,)- let settings = Submenu::new("Settings", true);+ let settings = Submenu::new(app.ui.language.tr("Settings"), true);+ titles.push(("Settings".into(), settings.clone()));for it in items.iter().filter(|i| i.id.starts_with("app.settings.")) {let label = it.label.trim_end_matches('…').to_string();let mi = MenuItem::with_id(it.id.clone(), label, true, it.shortcut.as_deref().and_then(accel));@@ -48,7 +50,8 @@ pub fn install(app: &FilmcraftApp, ctx: egui::Context) -> (Receiver<String>, Sho]);let _ = bar.append(&app_menu);for top in MENUS {- let sub = Submenu::new(top, true);+ let sub = Submenu::new(app.ui.language.tr(top), true);+ titles.push((top.into(), sub.clone()));let mine: Vec<&Item> = items.iter().filter(|i| i.path.first().map(String::as_str) == Some(top) && !i.id.starts_with("app.settings.")).collect();// submenus by path prefix (e.g. Clip ▸ Video Options ▸ Time Interpolation), created where// their first item appears@@ -62,7 +65,8 @@ pub fn install(app: &FilmcraftApp, ctx: egui::Context) -> (Receiver<String>, Shoparent = match subs.iter().find(|(k, _)| *k == key) {Some((_, s)) => s.clone(),None => {- let s = Submenu::new(&it.path[depth], true);+ let s = Submenu::new(app.ui.language.tr(&it.path[depth]), true);+ titles.push((it.path[depth].clone(), s.clone()));let _ = parent.append(&s);subs.push((key, s.clone()));s@@ -88,8 +92,17 @@ pub fn install(app: &FilmcraftApp, ctx: egui::Context) -> (Receiver<String>, Sho}});let update: ShortcutUpdater = Box::new(move |items: &[Item]| {+ let language = if items.iter().any(|it| it.id == "app.language.japanese" && it.checked == Some(true)) {+ filmcraft_ui_egui::i18n::Language::Ja+ } else {+ filmcraft_ui_egui::i18n::Language::En+ };+ for (title, submenu) in &titles {+ submenu.set_text(language.tr(title));+ }for (id, mi) in &native {if let Some(it) = items.iter().find(|i| &i.id == id) {+ mi.set_text(&it.label);let _ = mi.set_accelerator(it.shortcut.as_deref().and_then(accel));}}diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rsindex 6d205ed13..5fbe8327c 100644--- a/crates/text/src/layout.rs+++ b/crates/text/src/layout.rs@@ -850,6 +850,22 @@ mod tests {assert!((l2.lines[1].baseline - l2.lines[0].baseline - gap - 10.0).abs() < 1e-3);}+ #[test]+ fn japanese_vertical_titles_with_an_installed_font() {+ // Japanese glyphs come from a system font (none is bundled): skip where none is installed.+ crate::fonts::scan_system();+ if !crate::fonts::all_faces().iter().any(|f| "日本語縦書き".chars().all(|c| f.has_char(c))) {+ eprintln!("SKIPPED: no Japanese font installed");+ return;+ }+ let l = layout("日本語\n縦書き", &st(40.0), &ParagraphStyle { vertical: true, ..Default::default() });+ assert!(l.vertical);+ assert_eq!(l.glyphs.len(), 6);+ assert!(l.glyphs.iter().all(|g| g.id != 0));+ assert!(l.glyphs[1].y > l.glyphs[0].y);+ assert!(l.glyphs[3].x < l.glyphs[0].x);+ }+#[test]fn vertical_text_stacks_characters_in_columns() {let p = ParagraphStyle { vertical: true, ..Default::default() };diff --git a/crates/ui-egui/src/header.rs b/crates/ui-egui/src/header.rsindex ffd375715..96acc8113 100644--- a/crates/ui-egui/src/header.rs+++ b/crates/ui-egui/src/header.rs@@ -3,7 +3,7 @@//! live in the native menu bar (set up by the app); elsewhere a compact in-window menu bar follows//! the mode tabs.-use egui::{Align2, Color32, Rect, Sense, Stroke, pos2, vec2};+use egui::{Color32, Rect, Sense, Stroke, pos2, vec2};use crate::FilmcraftApp;use crate::icons::{self, Icon};@@ -54,6 +54,7 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {}x += gw + 24.0;}+ let mut left_end = x;// In-window menus when there is no native menu bar.if app.ui.show_menu_bar {let menu_rect = Rect::from_min_max(pos2(x + 6.0, rect.min.y + 7.0), pos2(x + 520.0, rect.max.y - 7.0));@@ -62,10 +63,10 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {mu.style_mut().visuals.widgets.inactive.bg_stroke = Stroke::NONE;mu.style_mut().visuals.override_text_color = Some(t.text_dim);crate::menus::menu_bar(app, &mut mu);+ left_end = mu.min_rect().max.x;}// Document title, centredlet title = format!("{}{}", app.session.project.name, if app.session.is_dirty() { " - Edited" } else { "" });- p.text(pos2(rect.center().x, rect.center().y), Align2::CENTER_CENTER, title, Tokens::ui(14.0), t.tab_text_active);// Right cluster: icons at ~38 pt pitch, then workspace name in caps.let mut rx = rect.max.x - 14.0;let mut btn = |ui: &mut egui::Ui, icon: Icon, id: &str, tip: &str, app: &mut FilmcraftApp| -> egui::Response {@@ -118,6 +119,23 @@ pub fn show(app: &mut FilmcraftApp, ui: &mut egui::Ui, rect: Rect) {ui.painter().rect_filled(r, 12.0, if resp.hovered() { t.accent_hover } else { t.accent });icons::paint(ui.painter(), Rect::from_center_size(pos2(r.min.x + 14.0, r.center().y), vec2(14.0, 14.0)), Icon::Chat, Color32::WHITE);ui.painter().galley(pos2(r.min.x + 25.0, r.center().y - g.size().y / 2.0), g, Color32::WHITE);+ // Localized menus and user titles can be wider than English. Use the actual gap.+ let left = left_end + 12.0;+ let right = r.min.x - 12.0;+ if right > left + 40.0 {+ let mut job = egui::text::LayoutJob::simple_singleline(title, Tokens::ui(14.0), t.tab_text_active);+ job.wrap.max_width = right - left;+ job.wrap.max_rows = 1;+ let galley = p.layout_job(job);+ let half = galley.size().x / 2.0;+ let center = if rect.center().x - half >= left && rect.center().x + half <= right { rect.center().x } else { (left + right) / 2.0 };+ p.with_clip_rect(Rect::from_min_max(pos2(left, rect.min.y), pos2(right, rect.max.y))).galley(+ pos2(center - half, rect.center().y - galley.size().y / 2.0),+ galley,+ t.tab_text_active,+ );+ }+if resp.clicked() {crate::links::open(ui.ctx(), crate::links::DISCORD);}diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rsnew file mode 100644index 000000000..ccd953df4--- /dev/null+++ b/crates/ui-egui/src/i18n.rs@@ -0,0 +1,259 @@+//! Interface translations. Command ids, document text and file names remain stable.+//! Untranslated labels fall back to English so coverage can grow incrementally.+//!+//! No Japanese font is bundled: Japanese uses a font already installed on the system+//! ([`system_japanese_font`]); without one, switching to Japanese is refused with a message.++use std::sync::{Arc, OnceLock};++#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]+#[serde(rename_all = "lowercase")]+pub enum Language {+ #[default]+ En,+ Ja,+}++impl Language {+ pub const ALL: [Self; 2] = [Self::En, Self::Ja];++ pub fn name(self) -> &'static str {+ match self {+ Self::En => "English",+ Self::Ja => "日本語",+ }+ }++ pub fn parse(code: &str) -> Option<Self> {+ match code {+ "en" => Some(Self::En),+ "ja" => Some(Self::Ja),+ _ => None,+ }+ }++ pub fn tr(self, text: &str) -> &str {+ if self == Self::Ja+ && let Some((_, japanese)) = JAPANESE.iter().find(|(english, _)| *english == text)+ {+ return japanese;+ }+ text+ }+}++/// Text every Japanese interface font must cover (menus use kanji, hiragana and katakana).+const JAPANESE_SAMPLE: &str = "日本語ファイル編集あア";++/// Installed families preferred for Japanese interface text, best first (Gothic / sans-serif faces+/// read best at menu sizes). Any other installed face that covers [`JAPANESE_SAMPLE`] is used if+/// none of these is present.+const PREFERRED_JAPANESE: &[&str] = &[+ "Hiragino Sans",+ "Hiragino Kaku Gothic ProN",+ "Hiragino Kaku Gothic Pro",+ "Yu Gothic UI",+ "Yu Gothic",+ "Meiryo UI",+ "Meiryo",+ "Noto Sans CJK JP",+ "Noto Sans JP",+ "Source Han Sans JP",+ "Source Han Sans",+ "IPAexGothic",+ "IPAGothic",+ "TakaoGothic",+ "VL Gothic",+];++const JAPANESE_FONT: &str = "system-japanese";++/// A Japanese font already installed on this system, for the interface (none is bundled). Looked up+/// once per process: the system font folders are scanned on first use (name tables only), then the+/// chosen face's file is read. `None` on the web and on systems without a Japanese font.+pub fn system_japanese_font() -> Option<Arc<egui::FontData>> {+ static FONT: OnceLock<Option<Arc<egui::FontData>>> = OnceLock::new();+ FONT.get_or_init(|| {+ filmcraft_text::fonts::scan_system();+ let faces: Vec<_> = filmcraft_text::fonts::all_faces().into_iter().filter(|f| f.info.origin == "system" && !f.info.italic).collect();+ let covers = |f: &filmcraft_text::fonts::Face| JAPANESE_SAMPLE.chars().all(|c| f.has_char(c));+ // within a family, the face closest to regular weight+ let by_weight = |f: &&Arc<filmcraft_text::fonts::Face>| f.info.weight.abs_diff(400);+ let preferred =+ PREFERRED_JAPANESE.iter().find_map(|name| faces.iter().filter(|f| f.info.family.eq_ignore_ascii_case(name) && covers(f)).min_by_key(by_weight));+ let face = preferred.or_else(|| faces.iter().filter(|f| covers(f)).min_by_key(by_weight))?;+ // kept for the life of the process (one font, read once) so installing it again after a+ // theme change shares the bytes instead of copying the whole file+ let bytes: &'static [u8] = Box::leak(face.data()?.into_boxed_slice());+ Some(Arc::new(egui::FontData { font: std::borrow::Cow::Borrowed(bytes), index: face.info.index, tweak: Default::default() }))+ })+ .clone()+}++/// Add the system's Japanese font as the last fallback of every theme font family, from the next+/// pass on. Returns false (and changes nothing) when no Japanese font is installed. Call it again+/// after `theme::install`, which replaces the font definitions.+pub fn install_japanese_font(ctx: &egui::Context) -> bool {+ let Some(font) = system_japanese_font() else { return false };+ let families = crate::theme::font_families()+ .into_iter()+ .map(|family| egui::epaint::text::InsertFontFamily { family, priority: egui::epaint::text::FontPriority::Lowest })+ .collect();+ // queued for the next pass (works before the first frame); a no-op when already installed+ ctx.add_font(egui::epaint::text::FontInsert { name: JAPANESE_FONT.into(), data: (*font).clone(), families });+ true+}++const JAPANESE: &[(&str, &str)] = &[+ ("Clip", "クリップ"),+ ("Sequence", "シーケンス"),+ ("Markers", "マーカー"),+ ("Graphics and Titles", "グラフィックスとタイトル"),+ ("Settings", "環境設定"),+ ("Object", "オブジェクト"),+ ("Effect", "効果"),+ ("Settings…", "環境設定…"),+ ("Image", "画像"),+ ("Layer", "レイヤー"),+ ("Type", "書式"),+ ("Select", "選択"),+ ("Filter", "フィルター"),+ ("Window", "ウィンドウ"),+ ("Language", "表示言語"),+ ("Save As…", "別名で保存…"),+ ("Exit", "終了"),+ ("New…", "新規…"),+ ("New", "新規"),+ ("Horizontal", "横書き"),+ ("Vertical", "縦書き"),+ ("Orientation", "組み方向"),+ ("Layers", "レイヤー"),+ ("History", "履歴"),+ ("Properties", "プロパティ"),+ ("Color", "カラー"),+ ("Brush Settings", "ブラシ設定"),+ ("Tools", "ツール"),+ ("Options", "オプション"),+ ("Zoom In", "ズームイン"),+ ("Zoom Out", "ズームアウト"),+ ("Fit on Screen", "画面に合わせる"),+ ("Copy", "コピー"),+ ("Cut", "切り取り"),+ ("Paste", "貼り付け"),+ ("Select All", "すべて選択"),+ ("Deselect", "選択を解除"),+ ("Export", "書き出し"),+ ("Export As…", "形式を指定して書き出し…"),+ ("Search…", "検索…"),+ ("Theme", "テーマ"),+ ("Menu", "メニュー"),+ ("File", "ファイル"),+ ("Edit", "編集"),+ ("Pages", "ページ"),+ ("View", "表示"),+ ("Help", "ヘルプ"),+ ("Preferences", "環境設定"),+ ("Preferences…", "環境設定…"),+ ("Interface language", "表示言語"),+ ("Open…", "開く…"),+ ("New blank PDF", "空白の PDF を作成"),+ ("Create PDF from file…", "ファイルから PDF を作成…"),+ ("Create PDF from images…", "画像から PDF を作成…"),+ ("Create PDF from clipboard", "クリップボードから PDF を作成"),+ ("Combine files…", "ファイルを結合…"),+ ("Save", "保存"),+ ("Save as…", "別名で保存…"),+ ("Close file", "ファイルを閉じる"),+ ("Close all", "すべて閉じる"),+ ("Revert", "保存済みの状態に戻す"),+ ("Print…", "印刷…"),+ ("Document properties…", "文書のプロパティ…"),+ ("Undo", "取り消し"),+ ("Redo", "やり直し"),+ ("Find…", "検索…"),+ ("Advanced search…", "高度な検索…"),+ ("Copy pages", "ページをコピー"),+ ("Cut pages", "ページを切り取り"),+ ("Paste pages", "ページを貼り付け"),+ ("Fit visible", "表示範囲に合わせる"),+ ("Marquee zoom", "範囲指定ズーム"),+ ("Take a snapshot", "スナップショットを作成"),+ ("Full screen mode", "全画面表示"),+ ("Read mode", "閲覧モード"),+ ("Switch light / dark theme", "明るい/暗いテーマを切り替え"),+ ("Comments panel", "コメントパネル"),+ ("Form fields panel", "フォームフィールドパネル"),+ ("Clear form", "フォームをクリア"),+ ("Find tools and commands…", "ツールとコマンドを検索…"),+ ("Zoom", "ズーム"),+ ("Actual size", "実際のサイズ"),+ ("Zoom to page level", "ページ全体を表示"),+ ("Fit to width", "幅に合わせる"),+ ("Display theme", "表示テーマ"),+ ("Side panels", "サイドパネル"),+ ("OK", "OK"),+];++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn translations_are_unique_and_preserve_unknown_text() {+ for (i, (en, ja)) in JAPANESE.iter().enumerate() {+ assert!(!ja.is_empty());+ assert!(JAPANESE.iter().take(i).all(|(other, _)| en != other));+ assert_eq!(Language::En.tr(en), *en);+ }+ assert_eq!(Language::Ja.tr("File"), "ファイル");+ assert_eq!(Language::Ja.tr("日本語の文書.pdf"), "日本語の文書.pdf");+ assert_eq!(Language::parse("xx"), None);+ }++ #[test]+ fn language_commands_switch_and_persist_without_a_document() {+ let mut app = crate::FilmcraftApp::new(filmcraft_engine::Session::default());+ let ctx = egui::Context::default();+ crate::menus::invoke(&mut app, &ctx, "app.language.japanese", serde_json::json!({})).unwrap();+ assert_eq!(app.ui.language, Language::Ja);+ let saved = serde_json::to_string(&app.ui).unwrap();+ let restored: crate::state::UiState = serde_json::from_str(&saved).unwrap();+ assert_eq!(restored.language, Language::Ja);+ crate::menus::invoke(&mut app, &ctx, "app.language.english", serde_json::json!({})).unwrap();+ assert_eq!(app.ui.language, Language::En);+ }++ #[test]+ fn japanese_needs_an_installed_font() {+ let mut app = crate::FilmcraftApp::new(filmcraft_engine::Session::default());+ let ctx = egui::Context::default();+ crate::theme::install(&ctx, &crate::theme::Tokens::for_kind(crate::theme::ThemeKind::default()));+ let r = crate::menus::invoke(&mut app, &ctx, "app.language.japanese", serde_json::json!({}));+ if system_japanese_font().is_none() {+ // nothing is bundled: refused, and the interface stays English+ assert!(r.is_err(), "{r:?}");+ assert_eq!(app.ui.language, Language::En);+ return;+ }+ assert!(r.is_ok(), "{r:?}");+ let mut output = ctx.run_ui(egui::RawInput::default(), |_| {});+ output.textures_delta.clear();+ ctx.fonts_mut(|fonts| {+ // every theme family falls back to the system Japanese font+ for family in crate::theme::font_families() {+ let stack = fonts.definitions().families.get(&family).cloned().unwrap_or_default();+ assert_eq!(stack.last().map(String::as_str), Some(JAPANESE_FONT), "{family:?}: {stack:?}");+ }+ // and the glyphs resolve. (Only families whose replacement-box face is another font:+ // egui's `has_glyph` reports false for any character served by the face it also uses+ // for the replacement box, which in the Inter-only "medium"/"semibold" stacks is the+ // Japanese font itself.)+ for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace] {+ let font = egui::FontId::new(13.0, family);+ for ch in JAPANESE_SAMPLE.chars() {+ assert!(fonts.has_glyph(&font, ch), "missing {ch} in {font:?}");+ }+ }+ });+ }+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 49618156c..fc9f6fc3d 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -13,6 +13,7 @@ pub mod crash;pub mod dock;pub mod frames;pub mod header;+pub mod i18n;pub mod icons;pub mod links;pub mod menus;@@ -854,8 +855,8 @@ impl FilmcraftApp {if self.bindings_rev != self.session.shortcuts.revision {self.bindings = menus::bindings(self);self.bindings_rev = self.session.shortcuts.revision;+ let items = menus::menu_items(self);if let Some(hook) = self.hooks.shortcuts_changed.as_mut() {- let items = menus::menu_items_for(&self.session);hook(&items);}}@@ -1235,6 +1236,11 @@ impl eframe::App for FilmcraftApp {fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {if !self.styled {theme::install(ctx, &self.tokens);+ // theme::install replaces the fonts: add the system Japanese font back (or fall back to+ // English when a saved Japanese setting meets a system without one)+ if self.ui.language == i18n::Language::Ja && !i18n::install_japanese_font(ctx) {+ self.ui.language = i18n::Language::En;+ }self.styled = true;ctx.request_repaint();} else {diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex a239efc02..ee924fe96 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -22,6 +22,8 @@ macro_rules! uic {}pub const UI_COMMANDS: &[UiCommand] = &[+ uic!("app.language.english", "English", ["Edit", "Language"], None),+ uic!("app.language.japanese", "日本語", ["Edit", "Language"], None),uic!("playback.toggle", "Play/Stop", [], Some("Space")),uic!("playback.forward", "Shuttle Right", [], Some("L")),uic!("playback.stop", "Shuttle Stop", [], Some("K")),@@ -144,6 +146,19 @@ pub fn panel_command_id(p: PanelKind) -> String {/// Execute a UI or engine command by id.pub fn invoke(app: &mut FilmcraftApp, ctx: &egui::Context, id: &str, params: Value) -> Result<Value, String> {+ if matches!(id, "app.language.english" | "app.language.japanese") {+ // no Japanese font is bundled: Japanese needs one installed on the system+ if id == "app.language.japanese" && !crate::i18n::install_japanese_font(ctx) {+ return Err("no Japanese font is installed on this system (for example Noto Sans CJK JP); the interface stays in English".into());+ }+ app.ui.language = if id == "app.language.japanese" { crate::i18n::Language::Ja } else { crate::i18n::Language::En };+ let items = menu_items(app);+ if let Some(hook) = app.hooks.shortcuts_changed.as_mut() {+ hook(&items);+ }+ ctx.request_repaint();+ return Ok(json!(app.ui.language));+ }if id == "perf.stats" {// the engine's counters plus playback, frame workers and UI timingsreturn Ok(crate::perf::stats(app));@@ -382,6 +397,12 @@ pub const MENUS: [&str; 9] = ["File", "Edit", "Clip", "Sequence", "Markers", "Grpub fn menu_items(app: &FilmcraftApp) -> Vec<MenuItem> {let mut v = menu_items_for(&app.session);for it in &mut v {+ it.label = app.ui.language.tr(&it.label).to_string();+ match it.id.as_str() {+ "app.language.english" => it.checked = Some(app.ui.language == crate::i18n::Language::En),+ "app.language.japanese" => it.checked = Some(app.ui.language == crate::i18n::Language::Ja),+ _ => {}+ }if it.id.starts_with("view.") {it.checked = crate::panels::monitor_view::checked(app, &it.id).or(crate::panels::menu_dialogs::checked(app, &it.id));it.enabled &= crate::panels::monitor_view::enabled(app, &it.id);@@ -518,13 +539,14 @@ pub fn external_commands() -> Vec<filmcraft_engine::shortcuts::CommandInfo> {/// Draw the in-window menu bar.pub fn menu_bar(app: &mut FilmcraftApp, ui: &mut egui::Ui) {+ ui.ctx().data_mut(|d| d.insert_temp(egui::Id::new("interface-language"), app.ui.language));let items = menu_items(app);let ctx = ui.ctx().clone();let mut clicked: Option<String> = None;egui::MenuBar::new().ui(ui, |ui| {for top in MENUS {let mine: Vec<&MenuItem> = items.iter().filter(|i| i.path.first().map(String::as_str) == Some(top)).collect();- ui.menu_button(top, |ui| {+ ui.menu_button(app.ui.language.tr(top), |ui| {ui.set_min_width(260.0);if mine.is_empty() {ui.add_enabled(false, egui::Button::new("(empty)"));@@ -549,7 +571,8 @@ fn menu_level(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, clicked: &mu}subs.push(sub);let inner: Vec<&MenuItem> = items.iter().copied().filter(|x| x.path.get(depth).map(String::as_str) == Some(sub)).collect();- ui.menu_button(sub, |ui| {+ let language = ui.ctx().data(|d| d.get_temp::<crate::i18n::Language>(egui::Id::new("interface-language"))).unwrap_or_default();+ ui.menu_button(language.tr(sub), |ui| {ui.set_min_width(220.0);menu_level(ui, &inner, depth + 1, clicked);});diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex 7a5f001a0..2468c94ec 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -344,6 +344,8 @@ pub enum GuideDialog {#[derive(Clone, Debug, Serialize, Deserialize)]pub struct UiState {+ #[serde(default)]+ pub language: crate::i18n::Language,pub tool: Tool,pub mode: Mode,pub workspace: String,@@ -721,6 +723,7 @@ fn yes() -> bool {impl Default for UiState {fn default() -> Self {Self {+ language: crate::i18n::Language::default(),tool: Tool::Selection,mode: Mode::Edit,workspace: "Editing".into(),diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rsindex 5191ef405..0a6f5f76e 100644--- a/crates/ui-egui/src/theme.rs+++ b/crates/ui-egui/src/theme.rs@@ -231,6 +231,12 @@ impl Tokens {}/// Install fonts (Inter, Inter SemiBold, JetBrains Mono) and egui visuals.+/// Every font family the theme defines (fallback fonts such as the system Japanese font are added to+/// each of them).+pub fn font_families() -> Vec<FontFamily> {+ vec![FontFamily::Proportional, FontFamily::Monospace, FontFamily::Name("semibold".into()), FontFamily::Name("medium".into())]+}+pub fn install(ctx: &egui::Context, t: &Tokens) {let mut fonts = FontDefinitions::default();fonts.font_data.insert("inter".into(), Arc::new(FontData::from_static(filmcraft_text::fonts::INTER_REGULAR)));