From 3a0b598fcb04869b37d22e2e8f18c7f569011b58 Mon Sep 17 00:00:00 2001 From: zitann2020 Date: Sat, 31 Oct 2026 02:47:27 +0900 Subject: [PATCH 1/2] i18n: every catalog names the platform's file manager (#1450) Co-Authored-By: DeepSeek V4.1 Flash --- crates/ui-egui/src/i18n.rs | 85 ++++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 35 deletions(-) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 9eed465e4..a1d3ded76 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -154,43 +154,40 @@ fn supported(locale: Option<&str>) -> &'static str { } } +/// The Windows and Linux sources of *Reveal in Finder* in each catalog that has them, keyed by +/// language code: the platform names the file manager before the catalog sees the label, so the +/// macOS row alone leaves the other two in English (#1450). +const REVEAL_FINDER: &[(&str, &str, &str)] = &[ + ("uk", "Показати у Провіднику", "Показати у файловому менеджері"), + ("de", "Im Explorer anzeigen", "Im Dateimanager anzeigen"), + ("cs", "Zobrazit v Průzkumníku", "Zobrazit ve správci souborů"), + ("ja", "エクスプローラーで表示", "ファイルマネージャーで表示"), + ("pl", "Pokaż w Eksploratorze", "Pokaż w menedżerze plików"), + ("ka", "Explorer-ში ჩვენება", "ფაილების მენეჯერში ჩვენება"), + ("zh-hans", "在资源管理器中显示", "在文件管理器中显示"), + ("zh-hant", "在檔案總管中顯示", "在檔案管理員中顯示"), + ("es", "Mostrar en el Explorador", "Mostrar en el gestor de archivos"), + ("pt-br", "Mostrar no Explorador", "Mostrar no gerenciador de arquivos"), + ("fr", "Afficher dans l’Explorateur", "Afficher dans le gestionnaire de fichiers"), + ("ru", "Показать в Проводнике", "Показать в файловом менеджере"), +]; + pub(crate) fn label<'a>(app: &EffectcraftApp, command: &str, source: &'a str) -> &'a str { let language = language(app); - // The engine names the platform's file manager before the catalog sees the label. These - // two commands keep their ids, but on Windows/Linux their source is no longer "Finder". - if language == "uk" && matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - match source { - "Reveal in Explorer" => return "Показати у Провіднику", - "Reveal in File Manager" => return "Показати у файловому менеджері", - _ => {} - } - } - if language == "de" && matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - match source { - "Reveal in Explorer" => return "Im Explorer anzeigen", - "Reveal in File Manager" => return "Im Dateimanager anzeigen", - _ => {} - } - } - if language == "cs" && matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - match source { - "Reveal in Explorer" => return "Zobrazit v Průzkumníku", - "Reveal in File Manager" => return "Zobrazit ve správci souborů", - _ => {} - } - } - if language == "pl" && matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - match source { - "Reveal in Explorer" => return "Pokaż w Eksploratorze", - "Reveal in File Manager" => return "Pokaż w menedżerze plików", - _ => {} - } - } - if language == "ka" && matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - match source { - "Reveal in Explorer" => return "Explorer-ში ჩვენება", - "Reveal in File Manager" => return "ფაილების მენეჯერში ჩვენება", - _ => {} + // The engine names the platform's file manager before the catalog sees the label, so on + // Windows and Linux the source is no longer "Finder" and the catalog's row misses. Every + // language that names a file manager says so here (#1450); a language with no row keeps the + // English source rather than a guess. + if matches!(command, "file.revealInFinder" | "layer.revealInFinder") { + for (code, explorer, manager) in REVEAL_FINDER { + if *code != language { + continue; + } + return match source { + "Reveal in Explorer" => *explorer, + "Reveal in File Manager" => *manager, + _ => source, + }; } } menu_catalog(language).map_or(source, |catalog| lookup(catalog, command, source)) @@ -8251,6 +8248,24 @@ mod tests { app.session.execute("prefs.set", json!({"key":"general.language", "value":"en"})).unwrap(); assert_eq!(label(&app, "", "Composition"), "Composition"); } + /// Every catalog names the platform's file manager: the engine substitutes it for "Finder" + /// before the label reaches the catalog, so the macOS row alone leaves Windows and Linux in + /// English (#1450). + #[test] + fn the_reveal_command_names_the_file_manager_in_every_catalog() { + let mut app = EffectcraftApp::new(effectcraft_engine::Session::default()); + for (code, explorer, manager) in REVEAL_FINDER { + app.session.execute("prefs.set", json!({"key":"general.language", "value": code})).unwrap(); + assert_eq!(label(&app, "file.revealInFinder", "Reveal in Explorer"), *explorer, "{code}"); + assert_eq!(label(&app, "layer.revealInFinder", "Reveal in File Manager"), *manager, "{code}"); + } + // English keeps the source, and the macOS wording still comes from the catalog. + app.session.execute("prefs.set", json!({"key":"general.language", "value": "en"})).unwrap(); + assert_eq!(label(&app, "file.revealInFinder", "Reveal in Explorer"), "Reveal in Explorer"); + app.session.execute("prefs.set", json!({"key":"general.language", "value": "ja"})).unwrap(); + assert_eq!(label(&app, "file.revealInFinder", "Reveal in Finder"), "Finderで表示"); + } + /// Match System in the browser also picks the Russian, French and German catalogs, in the /// order of the browser's preferences (#1700). #[test] From 96a6b257893cdeeff70d9a70d12f7c791df95ed6 Mon Sep 17 00:00:00 2001 From: zitann2020 Date: Sat, 31 Oct 2026 04:14:29 +0900 Subject: [PATCH 2/2] fixup: the macOS wording still comes from the catalog Co-Authored-By: DeepSeek V4.1 Flash --- crates/ui-egui/src/i18n.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index a1d3ded76..0696e9f03 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -178,16 +178,15 @@ pub(crate) fn label<'a>(app: &EffectcraftApp, command: &str, source: &'a str) -> // Windows and Linux the source is no longer "Finder" and the catalog's row misses. Every // language that names a file manager says so here (#1450); a language with no row keeps the // English source rather than a guess. - if matches!(command, "file.revealInFinder" | "layer.revealInFinder") { - for (code, explorer, manager) in REVEAL_FINDER { - if *code != language { - continue; - } - return match source { - "Reveal in Explorer" => *explorer, - "Reveal in File Manager" => *manager, - _ => source, - }; + if matches!(command, "file.revealInFinder" | "layer.revealInFinder") + && let Some((_, explorer, manager)) = REVEAL_FINDER.iter().find(|(code, ..)| *code == language) + { + // Only the Windows and Linux sources are overridden; "Reveal in Finder" keeps going to the + // catalog below, which holds the macOS wording. + match source { + "Reveal in Explorer" => return explorer, + "Reveal in File Manager" => return manager, + _ => {} } } menu_catalog(language).map_or(source, |catalog| lookup(catalog, command, source))