From 4d39068dfe12f176b6cee58debc86b99bc258df4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 08:59:44 -0800 Subject: [PATCH] i18n: the menu id test finds an id shown in backticks menu_items_never_show_an_id looked for a dotted id outside backticks only, so a label that was an id in backticks, or an effect id with no dot, passed. It now reads the label with its backticks removed and compares it with the item's command or effect id. --- crates/ui-egui/src/i18n/tests.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index fc98bdcff9..eb6b0cde72 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -1690,6 +1690,26 @@ fn menu_items_side_by_side_have_different_labels() { assert!(same.is_empty(), "{} pairs of menu items look alike:\n{}", same.len(), same.join("\n")); } +/// Whether a menu label shows an id: a dotted command id, inside backticks or outside them, or +/// `key`, the command or effect id of its item, on its own. +fn label_shows_an_id(label: &str, key: &str) -> bool { + let plain = label.replace('`', " "); + !command_ids(&plain).is_empty() || plain.trim() == key +} + +#[test] +fn label_shows_an_id_finds_ids_in_backticks_and_bare_keys() { + let key = "type.convertListToText"; + assert!(label_shows_an_id("type.convertListToText", key)); + assert!(label_shows_an_id("`type.convertListToText`", key)); + assert!(label_shows_an_id("`type.convertListToText", key)); + assert!(label_shows_an_id("Convert (`slice.list`)", key)); + assert!(label_shows_an_id("roughen", "roughen")); + assert!(label_shows_an_id("`roughen`", "roughen")); + assert!(!label_shows_an_id("Convert to Text", key)); + assert!(!label_shows_an_id("Roughen…", "roughen")); +} + /// Menu items show words, never the command or effect id their catalog row is keyed by. #[test] fn menu_items_never_show_an_id() { @@ -1698,7 +1718,7 @@ fn menu_items_never_show_an_id() { if let crate::menus::Item::Cmd(l, id, p) = item { let key = menu_item_effect(id, p).unwrap_or(id); let shown = shown_menu_label(lang, item).unwrap_or_default(); - if !command_ids(shown).is_empty() && command_ids(l).is_empty() { + if label_shows_an_id(shown, key) && !label_shows_an_id(l, key) { out.push(format!("{}: {l:?} ({key}) shows {shown:?}", lang.0.code)); } }