Dialogs: translate the texts a few dialogs draw themselves (#8056)

* Dialogs: translate the texts a few dialogs draw themselves

The joints' Play/Stop buttons, the Motion Study's Loop and the BOM's
sub-parts checkboxes, the Stitch tolerance hint, the Flange type and the
Emboss wrap note were drawn as English literals; the joint lists named
each joint's type by its Rust name (PinSlot, PointOnPlane). They now take
messages, and the joint lists use the Type box's label, translated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Move the new test away from where another open PR adds one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
semmelrindeandClaude Opus 5.5 authored and GitHub committed 2026-10-28 12:14:51 +00:00
1 parent 09308fceb1
commit d3b2c715d3
10 files changed
+189 -17

No files matched your search

+122
View File
@@ -0,0 +1,122 @@
{
"en": {
"bom.group_children": "Sub-parts in their part's row",
"sheet.flange_type_base": "Base",
"sheet.flange_type_contour": "Contour",
"sheet.flange_type_edge": "Edge",
"ui.emboss_wrap_note": "Orthogonal line profiles tangent to one supported cylinder wrap automatically. Pick a wall to choose a target.",
"ui.joint_play": "▶ Play",
"ui.joint_stop": "■ Stop",
"ui.stitch_tolerance_hint": "tight"
},
"ar": {
"bom.group_children": "الأجزاء الفرعية في صف الجزء الأصلي",
"sheet.flange_type_base": "أساسية",
"sheet.flange_type_contour": "محيط",
"sheet.flange_type_edge": "حافة",
"ui.emboss_wrap_note": "تلتف ملامح الخطوط المتعامدة المماسة لأسطوانة مدعومة تلقائيًا. اختر جدارًا لتحديد الهدف.",
"ui.joint_play": "▶ تشغيل",
"ui.joint_stop": "■ إيقاف",
"ui.stitch_tolerance_hint": "دقيقة"
},
"de": {
"bom.group_children": "Unterteile in der Zeile ihres Teils",
"sheet.flange_type_base": "Basislasche",
"sheet.flange_type_contour": "Konturlasche",
"sheet.flange_type_edge": "Kantenlasche",
"ui.emboss_wrap_note": "Senkrechte Linienprofile, die einen unterstützten Zylinder berühren, werden automatisch aufgewickelt. Eine Wand auswählen, um ein Ziel festzulegen.",
"ui.joint_play": "▶ Abspielen",
"ui.joint_stop": "■ Stopp",
"ui.stitch_tolerance_hint": "eng"
},
"es": {
"bom.group_children": "Subpiezas en la fila de su pieza",
"sheet.flange_type_base": "Base",
"sheet.flange_type_contour": "Contorno",
"sheet.flange_type_edge": "Arista",
"ui.emboss_wrap_note": "Los perfiles de líneas ortogonales tangentes a un cilindro compatible se envuelven automáticamente. Elegir una pared para definir el destino.",
"ui.joint_play": "▶ Reproducir",
"ui.joint_stop": "■ Detener",
"ui.stitch_tolerance_hint": "estricta"
},
"fr": {
"bom.group_children": "Sous-pièces dans la ligne de leur pièce",
"sheet.flange_type_base": "Base",
"sheet.flange_type_contour": "Contour",
"sheet.flange_type_edge": "Arête",
"ui.emboss_wrap_note": "Les profils de lignes orthogonales tangents à un cylindre pris en charge s'enroulent automatiquement. Choisir une paroi pour définir une cible.",
"ui.joint_play": "▶ Lire",
"ui.joint_stop": "■ Arrêter",
"ui.stitch_tolerance_hint": "serrée"
},
"he": {
"bom.group_children": "תת-חלקים בשורת החלק שלהם",
"sheet.flange_type_base": "בסיס",
"sheet.flange_type_contour": "מתאר",
"sheet.flange_type_edge": "מקצוע",
"ui.emboss_wrap_note": "פרופילי קווים ניצבים המשיקים לגליל נתמך נכרכים אוטומטית. יש לבחור דופן כדי לקבוע יעד.",
"ui.joint_play": "▶ הפעלה",
"ui.joint_stop": "■ עצירה",
"ui.stitch_tolerance_hint": "הדוקה"
},
"it": {
"bom.group_children": "Sottoparti nella riga della loro parte",
"sheet.flange_type_base": "Base",
"sheet.flange_type_contour": "Contorno",
"sheet.flange_type_edge": "Spigolo",
"ui.emboss_wrap_note": "I profili di linee ortogonali tangenti a un cilindro supportato si avvolgono automaticamente. Scegliere una parete per definire la destinazione.",
"ui.joint_play": "▶ Riproduci",
"ui.joint_stop": "■ Ferma",
"ui.stitch_tolerance_hint": "stretta"
},
"ja": {
"bom.group_children": "サブパーツを親パーツの行に含める",
"sheet.flange_type_base": "ベース",
"sheet.flange_type_contour": "輪郭",
"sheet.flange_type_edge": "エッジ",
"ui.emboss_wrap_note": "サポートされる円柱に接する直交線のプロファイルは自動的に巻き付けられます。対象を選ぶには壁を選択してください。",
"ui.joint_play": "▶ 再生",
"ui.joint_stop": "■ 停止",
"ui.stitch_tolerance_hint": "厳密"
},
"ko": {
"bom.group_children": "하위 부품을 상위 부품 행에 표시",
"sheet.flange_type_base": "베이스",
"sheet.flange_type_contour": "윤곽",
"sheet.flange_type_edge": "모서리",
"ui.emboss_wrap_note": "지원되는 원통에 접하는 직교 선 프로파일은 자동으로 감깁니다. 대상을 고르려면 벽을 선택하세요.",
"ui.joint_play": "▶ 재생",
"ui.joint_stop": "■ 정지",
"ui.stitch_tolerance_hint": "엄격"
},
"vi": {
"bom.group_children": "Chi tiết con trong hàng của chi tiết cha",
"sheet.flange_type_base": "Cơ sở",
"sheet.flange_type_contour": "Đường viền",
"sheet.flange_type_edge": "Cạnh",
"ui.emboss_wrap_note": "Các biên dạng đường trực giao tiếp xúc với một hình trụ được hỗ trợ sẽ tự động quấn. Chọn một thành để chọn mục tiêu.",
"ui.joint_play": "▶ Phát",
"ui.joint_stop": "■ Dừng",
"ui.stitch_tolerance_hint": "chặt"
},
"zh": {
"bom.group_children": "子零件并入所属零件的行",
"sheet.flange_type_base": "基体",
"sheet.flange_type_contour": "轮廓",
"sheet.flange_type_edge": "边线",
"ui.emboss_wrap_note": "与受支持圆柱相切的正交线轮廓会自动缠绕。选择一个壁以指定目标。",
"ui.joint_play": "▶ 播放",
"ui.joint_stop": "■ 停止",
"ui.stitch_tolerance_hint": "严格"
},
"zh-TW": {
"bom.group_children": "子零件併入所屬零件的列",
"sheet.flange_type_base": "基材",
"sheet.flange_type_contour": "輪廓",
"sheet.flange_type_edge": "邊線",
"ui.emboss_wrap_note": "與受支援圓柱相切的正交線輪廓會自動纏繞。選取一個壁以指定目標。",
"ui.joint_play": "▶ 播放",
"ui.joint_stop": "■ 停止",
"ui.stitch_tolerance_hint": "嚴格"
}
}
+1 -1
View File
@@ -115,7 +115,7 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
});
d.by_definition = grouping == 1;
ui.separator();
crate::ui_kit::checkbox(ui, "Sub-parts in their part's row", &mut d.group_children);
crate::ui_kit::checkbox(ui, crate::i18n::tr("bom.group_children"), &mut d.group_children);
if was != (d.top, d.by_definition, d.group_children) {
d.picked = None;
}
+41
View File
@@ -457,6 +457,47 @@ fn registry_dialog_inventory_has_no_unclassified_feature_forms() {
}
}
/// Texts these dialogs draw themselves read in the user's language: the joints' Play button, the
/// Motion Study's Loop, the Stitch tolerance hint, the Flange type and the Emboss note.
#[test]
fn hand_drawn_dialog_texts_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 [
("joint.gear", "▶ Play"),
("motion.study", "Loop"),
("surface.stitch", "tight"),
("sheet.flange", "Base"),
("solid.emboss", "Orthogonal line profiles tangent to one supported cylinder wrap automatically. Pick a wall to choose a target."),
] {
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: {painted:?}");
}
}
#[test]
fn revolve_layout_fixture_builds_a_valid_solid() {
let mut h = fixture();
+15 -4
View File
@@ -59,6 +59,16 @@ const TYPE_LABELS: [&str; 13] = [
"Point on line",
"Line on plane",
];
/// A joint type's label, as the Type box lists it ("Pin-slot", "Point on plane").
pub(crate) fn kind_label(kind: JointKind) -> &'static str {
TYPES.iter().position(|t| JointKind::parse(t) == Some(kind)).and_then(|i| TYPE_LABELS.get(i)).copied().unwrap_or("")
}
/// A joint as the joint lists name it: its name, and its type in the user's language.
pub(crate) fn joint_choice(name: &str, kind: JointKind) -> String {
format!("{name} ({})", crate::i18n::tr_label(kind_label(kind)))
}
/// What a joint origin input accepts (snaps on faces, edges and vertices).
pub const SNAPS: u16 = FACES | EDGES | VERTICES;
/// Commands whose effect is where occurrences sit (previewed on the placed model).
@@ -580,8 +590,10 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
let kind = f.joint_kind();
if kind != JointKind::Rigid {
form_row(ui, "Animate", |ui| {
let label = if f.animate { "■ Stop" } else { "▶ Play" };
if crate::ui_kit::button(ui, label, crate::ui_kit::Button::Normal).on_hover_text("Play the joint's motion in the view").clicked()
let label = crate::i18n::tr(if f.animate { "ui.joint_stop" } else { "ui.joint_play" });
if crate::ui_kit::button(ui, label, crate::ui_kit::Button::Normal)
.on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"))
.clicked()
{
f.animate = !f.animate;
}
@@ -640,8 +652,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Asm, inputs: &mut [Se
}
return false;
}
let labels: Vec<String> =
list.iter().filter_map(|i| s.doc.assembly.joints.get(*i)).map(|j| format!("{} ({:?})", j.name, j.kind)).collect();
let labels: Vec<String> = list.iter().filter_map(|i| s.doc.assembly.joints.get(*i)).map(|j| joint_choice(&j.name, j.kind)).collect();
let refs: Vec<&str> = labels.iter().map(String::as_str).collect();
// On a rigid joint the box shows none of the joints that move until one is chosen.
let mut pos = list.iter().position(|i| i == joint).unwrap_or(list.len());
+2 -2
View File
@@ -46,7 +46,7 @@ pub struct CamForm {
/// Joints of a kind: (id, label).
fn joints_of(s: &Session, kinds: &[JointKind]) -> Vec<(u64, String)> {
s.doc.assembly.joints.iter().filter(|j| kinds.contains(&j.kind)).map(|j| (j.id, format!("{} ({:?})", j.name, j.kind))).collect()
s.doc.assembly.joints.iter().filter(|j| kinds.contains(&j.kind)).map(|j| (j.id, crate::dialogs_assembly::joint_choice(&j.name, j.kind))).collect()
}
pub fn start(app: &SolveApp) -> (Asm, Vec<SelInput>) {
@@ -133,7 +133,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CamForm, inputs: &[Se
}
crate::ui_kit::options(ui, "cam_options", &mut [("Other side", &mut f.flip)]);
form_row(ui, "Animate", |ui| {
let label = if f.animate { "■ Stop" } else { "▶ Play" };
let label = crate::i18n::tr(if f.animate { "ui.joint_stop" } else { "ui.joint_play" });
let r = crate::ui_kit::button(ui, label, crate::ui_kit::Button::Normal)
.on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
crate::scenario::publish_handle("dialog:Animate", r.rect.center());
+2 -2
View File
@@ -46,7 +46,7 @@ fn joints_that(s: &Session, turn: bool) -> Vec<(u64, String)> {
.joints
.iter()
.filter(|j| (0..j.kind.dofs().len()).any(|i| j.kind.is_angle(i) == turn))
.map(|j| (j.id, format!("{} ({:?})", j.name, j.kind)))
.map(|j| (j.id, crate::dialogs_assembly::joint_choice(&j.name, j.kind)))
.collect()
}
@@ -206,7 +206,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, f: &mut CouplingForm, inputs:
ui.label(RichText::new(shown.unwrap_or_else(|| "-".into())).color(t.text_dim));
});
form_row(ui, "Animate", |ui| {
let label = if f.animate { "■ Stop" } else { "▶ Play" };
let label = crate::i18n::tr(if f.animate { "ui.joint_stop" } else { "ui.joint_play" });
let r = crate::ui_kit::button(ui, label, crate::ui_kit::Button::Normal)
.on_hover_text(crate::i18n::tr_label("Play the joint's motion in the view"));
crate::scenario::publish_handle("dialog:Animate", r.rect.center());
+1 -4
View File
@@ -732,10 +732,7 @@ fn additional_rows(app: &mut SolveApp, d: &mut Dialog, ui: &mut egui::Ui) -> boo
ui_kit::segmented(ui, &mut i, &["Emboss", "Deboss"], Default::default());
*deboss = i == 1;
});
ui.add(
egui::Label::new("Orthogonal line profiles tangent to one supported cylinder wrap automatically. Pick a wall to choose a target.")
.wrap(),
);
ui.add(egui::Label::new(crate::i18n::tr("ui.emboss_wrap_note")).wrap());
}
Kind::Align { flip } => {
// Where on the picked face or edge to snap: as picked (a face turns to meet
+1 -1
View File
@@ -599,7 +599,7 @@ fn motion_study_rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Mo, inputs:
*playing = false;
}
ui.add_space(t.space_6);
crate::ui_kit::checkbox(ui, "Loop", looping);
crate::ui_kit::checkbox(ui, crate::i18n::tr_label("Loop"), looping);
let names: Vec<String> = SPEEDS.iter().map(|x| format!("{x}×")).collect();
let refs: Vec<&str> = names.iter().map(String::as_str).collect();
ui.allocate_ui(vec2(t.form_label_width, t.control_height), |ui| combo(ui, "ms_speed", &refs, speed));
+3 -2
View File
@@ -23,7 +23,8 @@ const PERFORATION_LABELS: [&str; 2] = ["ui.perforate_staggered", "ui.perforate_s
const FOLD_POSITIONS: [&str; 4] = ["centerline", "start", "end", "mould"];
const FOLD_POSITION_LABELS: [&str; 4] = ["Centerline", "Start of Bend", "End of Bend", "Outside Mould Line"];
const FLANGE_TYPES: [&str; 3] = ["Base", "Edge", "Contour"];
/// The flange types' messages, by the type's index (Base, Edge, Contour).
const FLANGE_TYPES: [&str; 3] = ["sheet.flange_type_base", "sheet.flange_type_edge", "sheet.flange_type_contour"];
const POSITIONS: [&str; 5] = ["inside", "outside", "middle", "material_outside", "tangent"];
const POSITION_LABELS: [&str; 5] = ["Inside", "Outside", "Middle", "Material Outside", "Tangent to Edge"];
/// Where an edge flange's height is measured from (`height_from`; the first is the default).
@@ -242,7 +243,7 @@ pub fn rows(app: &mut SolveApp, ui: &mut egui::Ui, k: &mut Sm, inputs: &mut [Sel
Sm::Flange { ty, height, angle, radius, position, height_from, flip, distance, reverse, rule, own, relief, relief_size, then } => {
*ty = flange_type(inputs);
form_row(ui, "Type", |ui| {
ui.label(FLANGE_TYPES.get(*ty).copied().unwrap_or(""));
ui.label(FLANGE_TYPES.get(*ty).copied().map(crate::i18n::tr).unwrap_or(""));
});
match *ty {
1 => {
+1 -1
View File
@@ -225,7 +225,7 @@ pub fn rows(ui: &mut egui::Ui, k: &mut Surf) -> bool {
let mut enter = false;
match k {
Surf::Stitch { tolerance } => {
enter |= hint_row(ui, "Tolerance", tolerance, "tight");
enter |= hint_row(ui, "Tolerance", tolerance, crate::i18n::tr("ui.stitch_tolerance_hint"));
}
Surf::Thicken { thickness, symmetric, operation } => {
enter |= expr_row(ui, "Thickness", thickness);