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.
This commit is contained in:
dotCooCoo committed 2026-11-14 08:59:44 -08:00
1 parent dd08ea5f78
commit 4d39068dfe
1 file changed
+21 -1
+21 -1
View File
@@ -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));
}
}