From 64ba4f59d1a3f05e7c01b0249c2ce584e56d39a8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 11:51:40 -0800 Subject: [PATCH] Last Effect: a plug-in's translated name is not translated again Last Effect shows a live-effect plug-in's name in the UI language as the plug-in's translations give it, even where it matches text the app translates ("Open" in German stays "Open"). --- crates/ui-egui/src/menus/labels.rs | 4 +++- crates/ui-egui/src/tests/plugins.rs | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus/labels.rs b/crates/ui-egui/src/menus/labels.rs index 365315facb..c1a06ea48a 100644 --- a/crates/ui-egui/src/menus/labels.rs +++ b/crates/ui-egui/src/menus/labels.rs @@ -194,8 +194,10 @@ pub fn display_label(app: &VectorcraftApp, id: &str, label: &str) -> String { } "effect.last" => match &app.last_effect { Some((e, _)) => { + // A plug-in's name is already in the UI language from its translations. let name = last_effect_name(e); - fmt(tl!("Last Effect: {name}"), &[("name", crate::i18n::tr_id(lang, e, name))]) + let name = if vectorcraft_plugins::effect::plugin_id(e).is_some() { name } else { crate::i18n::tr_id(lang, e, name) }; + fmt(tl!("Last Effect: {name}"), &[("name", name)]) } None => crate::i18n::tr_id(lang, id, label).to_string(), }, diff --git a/crates/ui-egui/src/tests/plugins.rs b/crates/ui-egui/src/tests/plugins.rs index 030b6bfb55..dec0b39419 100644 --- a/crates/ui-egui/src/tests/plugins.rs +++ b/crates/ui-egui/src/tests/plugins.rs @@ -845,6 +845,26 @@ fn plugin_menus_show_the_plugins_names_in_the_ui_language() { } } +/// Last Effect shows a live-effect plug-in's translated name as the plug-in gives it, even where it +/// matches text the app translates: "Open" in German stays "Open". +#[test] +fn last_effect_leaves_a_plugins_translated_name_as_it_gives_it() { + let mut app = app(); + let effect = "test.ui.translated.last_effect"; + let manifest = format!(r#"{{"id":"{effect}","name":"Unseal","kind":"effect","translations":{{"de":{{"name":"Open"}}}}}}"#); + let module = wat::parse_str(tpl::returning(&manifest, r#"{"objects":[]}"#)).unwrap(); + app.run("plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(&module)})).unwrap(); + app.last_effect = Some((vectorcraft_plugins::effect::effect_id(effect), json!({}))); + let de = crate::i18n::Lang::from_code("de").unwrap(); + crate::i18n::set_current(de); + let shown = menus::display_label(&app, "effect.last", "Last Effect…"); + crate::i18n::set_current(crate::i18n::Lang::EN); + app.last_effect = None; + app.run("plugin.remove", json!({"id": effect})).unwrap(); + assert_ne!(crate::i18n::tr(de, "Open"), "Open", "German translates the app's Open"); + assert_eq!(shown, crate::i18n::fmt(crate::i18n::tr(de, "Last Effect: {name}"), &[("name", "Open")])); +} + /// Keyboard Shortcuts shows a plug-in command's label and its plug-in's name as the plug-in gives /// them, even where they match text the app translates: in German, a command labeled "Open" of a /// plug-in named "Close" keeps both, as in its menu.