Motion dialogs: translate the notes and refusals they draw themselves (#8096)

Motion Study, Motion Trace, the motion plot, Explode and the contact
check drew their notes and refusals as they got them ("add a key for a
joint first", "select a point on a component", "none"), so they read
English in every language. They now go through the label translator, and
the four that no catalog carried get messages.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
semmelrinde
2026-10-28 12:13:38 +00:00
committed by GitHub
parent dfa9afd39f
commit bf1886e90a
5 changed files with 117 additions and 7 deletions
+74
View File
@@ -0,0 +1,74 @@
{
"en": {
"add a key for a joint first": "add a key for a joint first",
"no motion study yet": "no motion study yet",
"no such joint": "no such joint",
"select a point on a component": "select a point on a component"
},
"ar": {
"add a key for a joint first": "أضف أولًا مفتاحًا لمفصل",
"no motion study yet": "لا توجد دراسة حركة بعد",
"no such joint": "لا يوجد مفصل بهذا الاسم",
"select a point on a component": "اختر نقطة على مكوّن"
},
"de": {
"add a key for a joint first": "zuerst einen Schlüssel für ein Gelenk hinzufügen",
"no motion study yet": "noch keine Bewegungsuntersuchung",
"no such joint": "kein solches Gelenk",
"select a point on a component": "einen Punkt auf einer Komponente auswählen"
},
"es": {
"add a key for a joint first": "añade primero una clave para una unión",
"no motion study yet": "todavía no hay ningún estudio de movimiento",
"no such joint": "no existe esa unión",
"select a point on a component": "selecciona un punto en un componente"
},
"fr": {
"add a key for a joint first": "ajouter d'abord une clé pour une liaison",
"no motion study yet": "pas encore d'étude de mouvement",
"no such joint": "liaison introuvable",
"select a point on a component": "sélectionner un point sur un composant"
},
"he": {
"add a key for a joint first": "יש להוסיף תחילה מפתח למפרק",
"no motion study yet": "אין עדיין חקר תנועה",
"no such joint": "אין מפרק כזה",
"select a point on a component": "יש לבחור נקודה על רכיב"
},
"it": {
"add a key for a joint first": "aggiungi prima una chiave per un giunto",
"no motion study yet": "ancora nessuno studio del movimento",
"no such joint": "giunto inesistente",
"select a point on a component": "seleziona un punto su un componente"
},
"ja": {
"add a key for a joint first": "先にジョイントのキーを追加してください",
"no motion study yet": "モーション スタディがまだありません",
"no such joint": "そのジョイントはありません",
"select a point on a component": "コンポーネント上の点を選択してください"
},
"ko": {
"add a key for a joint first": "먼저 관절의 키를 추가하세요",
"no motion study yet": "아직 운동 연구가 없습니다",
"no such joint": "해당 관절이 없습니다",
"select a point on a component": "구성요소 위의 점을 선택하세요"
},
"vi": {
"add a key for a joint first": "hãy thêm một khóa cho khớp trước",
"no motion study yet": "chưa có nghiên cứu chuyển động",
"no such joint": "không có khớp này",
"select a point on a component": "chọn một điểm trên một thành phần"
},
"zh": {
"add a key for a joint first": "请先为接头添加关键帧",
"no motion study yet": "尚无运动分析",
"no such joint": "没有这个接头",
"select a point on a component": "选择组件上的一个点"
},
"zh-TW": {
"add a key for a joint first": "請先為接頭新增關鍵影格",
"no motion study yet": "尚無運動研究",
"no such joint": "沒有這個接頭",
"select a point on a component": "選取元件上的一個點"
}
}
+36
View File
@@ -255,6 +255,42 @@ form_case!(shell, "solid.shell", ["Thickness", "Direction"]);
form_case!(draft, "solid.draft", ["Angle"]);
form_case!(mirror, "solid.mirror", ["Operation"]);
/// The Motion Study's and Motion Trace's hints read in the user's language: the dialogs drew them
/// as they got them, in English.
#[test]
fn motion_dialog_hints_are_translated() {
fn texts(shape: &egui::Shape, out: &mut Vec<String>) {
match shape {
egui::Shape::Text(text) => out.push(text.galley.job.text.clone()),
egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| texts(shape, out)),
_ => {}
}
}
let mut h = fixture();
h.app.preferences.language = "ja".into();
let _japanese = crate::i18n::scope("ja");
for (command, english) in [("motion.study", "add a key for a joint first"), ("motion.trace", "select a point on a component")] {
let mut d = Dialog::for_command(&h.app, command).unwrap();
let mut painted = Vec::new();
for _ in 0..2 {
let mut out = h.ctx.run_ui(
egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(320.0, 1600.0))), ..Default::default() },
|ui| {
ui.set_width(264.0);
ui_kit::scope(ui, |ui| {
rows(&mut h.app, &h.ctx, &mut d, ui);
});
},
);
out.textures_delta.clear();
painted.clear();
out.shapes.iter().for_each(|shape| texts(&shape.shape, &mut painted));
}
assert!(!painted.iter().any(|p| p == english), "{command} paints {english:?} in Japanese");
assert!(painted.iter().any(|p| p == crate::i18n::tr_label(english)), "{command} paints {painted:?}");
}
}
fn mirror_preselection() -> (Harness, Vec<Sel>) {
let mut h = Harness::new();
h.app.run("sketch.create", json!({"plane":"XY","name":"Sketch1"})).unwrap();
+4 -4
View File
@@ -490,9 +490,9 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Mo, inputs: &mut [Sel
let hits = c.get("collisions").and_then(Value::as_array).cloned().unwrap_or_default();
crate::ui_kit::section(ui, "contact_collisions", "Collisions", true, |ui| {
if let Some(e) = c.get("error").and_then(Value::as_str) {
ui.label(RichText::new(e).color(t.error));
ui.label(RichText::new(crate::i18n::tr_label(e)).color(t.error));
} else if hits.is_empty() {
ui.label(RichText::new("none").color(t.text_dim));
ui.label(RichText::new(crate::i18n::tr_label("none")).color(t.text_dim));
} else {
ui.vertical(|ui| {
for h in hits {
@@ -530,7 +530,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Mo, inputs: &mut [Sel
}
if let Some(e) = error {
ui.vertical(|ui| {
ui.label(RichText::new(e.as_str()).color(t.error));
ui.label(RichText::new(crate::i18n::tr_label(e)).color(t.error));
});
}
}
@@ -737,7 +737,7 @@ fn motion_study_rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Mo, inputs:
}
if let Some(e) = error {
ui.vertical(|ui| {
ui.label(RichText::new(e.as_str()).color(t.text_dim));
ui.label(RichText::new(crate::i18n::tr_label(e)).color(t.text_dim));
});
}
enter
+2 -2
View File
@@ -317,7 +317,7 @@ fn collision_rows(
}
Some(Err(e)) => {
ui.vertical(|ui| {
ui.add(egui::Label::new(RichText::new(e.as_str()).color(t.error)).wrap());
ui.add(egui::Label::new(RichText::new(crate::i18n::tr_label(e)).color(t.error)).wrap());
});
}
None => {}
@@ -385,7 +385,7 @@ fn plot_rows(
});
}
Some(Err(e)) => {
ui.add(egui::Label::new(RichText::new(e.as_str()).color(t.text_dim)).wrap());
ui.add(egui::Label::new(RichText::new(crate::i18n::tr_label(e)).color(t.text_dim)).wrap());
}
None => {}
});
+1 -1
View File
@@ -196,7 +196,7 @@ pub fn rows(app: &mut crate::SolveApp, ui: &mut egui::Ui, f: &mut TraceForm, inp
Some(why) => (why, t.warning),
None => (crate::i18n::format("trace.points", &[("count", &v["samples"].to_string())]), t.text_dim),
},
Err(e) => (e.clone(), t.text_dim),
Err(e) => (crate::i18n::tr_label(e).to_string(), t.text_dim),
};
form_row(ui, "", |ui| {
ui.add(egui::Label::new(RichText::new(text).color(colour)).wrap());