From c2e69ed724b504b09bd820b0d0c5783d6e34bb7e Mon Sep 17 00:00:00 2001 From: Colin Faulkingham Date: Wed, 28 Oct 2026 18:55:37 +0000 Subject: [PATCH] Timeline: the feature menu's suppress item follows the reader's language (#8301) (#8383) * claim: #8301 * Timeline: the feature menu's suppress item follows the reader's language (#8301) Suppress Features / Unsuppress Features were raw literals. Menu::label() translates a label only when a catalog entry carries it, and none did, so the item stayed English in every language, the Japanese UI included. The two labels are now the messages timeline.suppress_features and timeline.unsuppress_features in a new assets/locales/pending file: the English wording is unchanged, and the complete catalogs (ar, he, ja, vi, zh) plus de and ko carry the translations. cargo test --profile ci -p solidcraft-ui-egui --lib -- timeline::tests::the_feature_menu_suppress_item_follows_the_language fails on the claim commit (the Japanese menu paints the English literal) and passes with the change. --- .../pending/timeline-suppress-labels.json | 34 ++++++++++++++++ crates/ui-egui/src/timeline.rs | 40 ++++++++++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 assets/locales/pending/timeline-suppress-labels.json diff --git a/assets/locales/pending/timeline-suppress-labels.json b/assets/locales/pending/timeline-suppress-labels.json new file mode 100644 index 000000000..de4e4eca3 --- /dev/null +++ b/assets/locales/pending/timeline-suppress-labels.json @@ -0,0 +1,34 @@ +{ + "en": { + "timeline.suppress_features": "Suppress Features", + "timeline.unsuppress_features": "Unsuppress Features" + }, + "ja": { + "timeline.suppress_features": "フィーチャーを抑制", + "timeline.unsuppress_features": "フィーチャーの抑制を解除" + }, + "zh": { + "timeline.suppress_features": "抑制特征", + "timeline.unsuppress_features": "取消抑制特征" + }, + "de": { + "timeline.suppress_features": "Merkmale unterdrücken", + "timeline.unsuppress_features": "Unterdrückung der Merkmale aufheben" + }, + "ko": { + "timeline.suppress_features": "특성 비활성화", + "timeline.unsuppress_features": "특성 비활성화 해제" + }, + "ar": { + "timeline.suppress_features": "تعطيل الميزات", + "timeline.unsuppress_features": "إلغاء تعطيل الميزات" + }, + "he": { + "timeline.suppress_features": "השבתת פיצ'רים", + "timeline.unsuppress_features": "ביטול השבתת פיצ'רים" + }, + "vi": { + "timeline.suppress_features": "Bỏ kích hoạt các tính năng", + "timeline.unsuppress_features": "Kích hoạt lại các tính năng" + } +} diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rs index 0c82e48a2..7eadd82ae 100644 --- a/crates/ui-egui/src/timeline.rs +++ b/crates/ui-egui/src/timeline.rs @@ -652,7 +652,10 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) { app.dialog = Some(crate::dialogs::Dialog::rename(*id, name)); ui.close(); } - if crate::context_menu::button(ui, if *suppressed { "Unsuppress Features" } else { "Suppress Features" }, "suppress").clicked() { + // Its own message, not a literal: no catalog held the literal, so the item + // stayed English in every language (#8301). + let suppress = if *suppressed { "timeline.unsuppress_features" } else { "timeline.suppress_features" }; + if crate::context_menu::button(ui, crate::i18n::tr(suppress), "suppress").clicked() { let _ = app.run_heavy("timeline.suppress", json!({"feature": id})); ui.close(); } @@ -825,6 +828,41 @@ mod tests { } } + /// #8301: the feature menu's suppress item is drawn from the catalog, so it follows the + /// reader's language. The literals it used were in no catalog and stayed English in every + /// language, the Japanese UI included. + #[test] + fn the_feature_menu_suppress_item_follows_the_language() { + let mut h = two_boxes(false); + h.app.preferences.language = "ja".into(); + h.frames(2); + let painted = |h: &Harness| -> Vec { + let output = egui::FullOutput { shapes: h.shapes.clone(), ..Default::default() }; + crate::test_support::text_shapes(&output).map(|t| t.galley.text().to_string()).collect() + }; + // No English on screen: the item shows the reader's language. + h.step(&json!({"click": {"handle": "timeline:First"}, "button": "right"})).unwrap(); + let texts = painted(&h); + assert!(!texts.iter().any(|t| t == "Suppress Features"), "the English literal is painted in the Japanese UI: {texts:?}"); + let ja = crate::i18n::Locale::for_language("ja").text("timeline.suppress_features").to_string(); + let ja_unsuppress = crate::i18n::Locale::for_language("ja").text("timeline.unsuppress_features").to_string(); + assert!(texts.contains(&ja), "the item must read {ja}: {texts:?}"); + h.step(&json!({"key": "Escape"})).unwrap(); + // A suppressed feature offers the other way round. + let first = h.app.session.doc.find_feature("First").map(|f| f.id).unwrap(); + h.app.run("timeline.suppress", json!({"feature": first, "suppressed": true})).unwrap(); + h.frames(2); + h.step(&json!({"click": {"handle": "timeline:First"}, "button": "right"})).unwrap(); + let texts = painted(&h); + assert!(!texts.iter().any(|t| t == "Unsuppress Features"), "the English literal is painted in the Japanese UI: {texts:?}"); + assert!(texts.contains(&ja_unsuppress), "the item must read {ja_unsuppress}: {texts:?}"); + h.step(&json!({"key": "Escape"})).unwrap(); + // The English wording is the one the menu always showed: the change adds messages, it + // does not reword the item. + assert_eq!(crate::i18n::Locale::for_language("en").text("timeline.suppress_features"), "Suppress Features"); + assert_eq!(crate::i18n::Locale::for_language("en").text("timeline.unsuppress_features"), "Unsuppress Features"); + } + #[test] fn construction_history_matches_the_tool_that_created_it() { use solidcraft_engine::doc::{