Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Sketch: the status in the view and the browser's editing mark in the user's language (#8084)

semmelrindefed960535775
diff --git a/assets/locales/pending/sketch-status-texts.json b/assets/locales/pending/sketch-status-texts.json
new file mode 100644
index 0000000000..669eccba94
--- /dev/null
+++ b/assets/locales/pending/sketch-status-texts.json
@@ -0,0 +1,74 @@
+{
+ "en": {
+ "browser.sketch_attachment_lost": "{name} (attachment lost)",
+ "browser.sketch_editing": "{name} (editing)",
+ "sketch.status_conflict": "constraints conflict",
+ "sketch.status_fully_constrained": "fully constrained"
+ },
+ "ar": {
+ "browser.sketch_attachment_lost": "{name} (فُقد الارتباط)",
+ "browser.sketch_editing": "{name} (قيد التحرير)",
+ "sketch.status_conflict": "تعارض القيود",
+ "sketch.status_fully_constrained": "مقيّد بالكامل"
+ },
+ "de": {
+ "browser.sketch_attachment_lost": "{name} (Bezug verloren)",
+ "browser.sketch_editing": "{name} (in Bearbeitung)",
+ "sketch.status_conflict": "Bedingungen widersprechen sich",
+ "sketch.status_fully_constrained": "vollständig bestimmt"
+ },
+ "es": {
+ "browser.sketch_attachment_lost": "{name} (fijación perdida)",
+ "browser.sketch_editing": "{name} (en edición)",
+ "sketch.status_conflict": "restricciones en conflicto",
+ "sketch.status_fully_constrained": "totalmente restringido"
+ },
+ "fr": {
+ "browser.sketch_attachment_lost": "{name} (attache perdue)",
+ "browser.sketch_editing": "{name} (en cours de modification)",
+ "sketch.status_conflict": "contraintes en conflit",
+ "sketch.status_fully_constrained": "entièrement contrainte"
+ },
+ "he": {
+ "browser.sketch_attachment_lost": "{name} (ההצמדה אבדה)",
+ "browser.sketch_editing": "{name} (בעריכה)",
+ "sketch.status_conflict": "אילוצים סותרים",
+ "sketch.status_fully_constrained": "מאולץ במלואו"
+ },
+ "it": {
+ "browser.sketch_attachment_lost": "{name} (aggancio perso)",
+ "browser.sketch_editing": "{name} (in modifica)",
+ "sketch.status_conflict": "vincoli in conflitto",
+ "sketch.status_fully_constrained": "completamente vincolato"
+ },
+ "ja": {
+ "browser.sketch_attachment_lost": "{name} (アタッチメント消失)",
+ "browser.sketch_editing": "{name} (編集中)",
+ "sketch.status_conflict": "拘束が競合しています",
+ "sketch.status_fully_constrained": "完全拘束"
+ },
+ "ko": {
+ "browser.sketch_attachment_lost": "{name} (부착 해제됨)",
+ "browser.sketch_editing": "{name} (편집 중)",
+ "sketch.status_conflict": "구속 조건 충돌",
+ "sketch.status_fully_constrained": "완전 구속"
+ },
+ "vi": {
+ "browser.sketch_attachment_lost": "{name} (mất liên kết)",
+ "browser.sketch_editing": "{name} (đang sửa)",
+ "sketch.status_conflict": "ràng buộc xung đột",
+ "sketch.status_fully_constrained": "ràng buộc hoàn toàn"
+ },
+ "zh": {
+ "browser.sketch_attachment_lost": "{name} (附着丢失)",
+ "browser.sketch_editing": "{name} (编辑中)",
+ "sketch.status_conflict": "约束冲突",
+ "sketch.status_fully_constrained": "完全约束"
+ },
+ "zh-TW": {
+ "browser.sketch_attachment_lost": "{name} (附著遺失)",
+ "browser.sketch_editing": "{name} (編輯中)",
+ "sketch.status_conflict": "拘束衝突",
+ "sketch.status_fully_constrained": "完全拘束"
+ }
+}
diff --git a/crates/ui-egui/src/browser.rs b/crates/ui-egui/src/browser.rs
index e794ea88f2..b49a587e02 100644
--- a/crates/ui-egui/src/browser.rs
+++ b/crates/ui-egui/src/browser.rs
@@ -2032,9 +2032,9 @@ impl Entry {
thing: Thing::Sketch(f.id),
patterns: crate::sketch_pattern_tree::has_patterns(app, f.id).then(|| format!("s:{}/patterns", f.id)),
label: if lost {
- format!("{} (attachment lost)", f.name)
+ crate::i18n::format("browser.sketch_attachment_lost", &[("name", &crate::i18n::tr_name(&f.name))])
} else if active {
- format!("{} (editing)", f.name)
+ crate::i18n::format("browser.sketch_editing", &[("name", &crate::i18n::tr_name(&f.name))])
} else {
f.name.clone()
},
diff --git a/crates/ui-egui/src/browser_model_tests.rs b/crates/ui-egui/src/browser_model_tests.rs
index 89dfb43f3e..9e69310237 100644
--- a/crates/ui-egui/src/browser_model_tests.rs
+++ b/crates/ui-egui/src/browser_model_tests.rs
@@ -409,3 +409,14 @@ fn browser_rows_still_fold_or_select_when_move_copy_is_not_open() {
click(&mut h, "row:Bodies");
assert!(h.app.tree.collapsed.contains("c0/bodies"));
}
+
+/// The sketch being edited is marked in the user's language, not with an English "(editing)",
+/// and its default name reads as the browser shows it elsewhere.
+#[test]
+fn the_edited_sketch_is_marked_in_the_users_language() {
+ let mut h = crate::scenario::Harness::new();
+ h.app.run("sketch.create", json!({"plane":"XY","name":"Sketch1"})).unwrap();
+ let _japanese = crate::i18n::scope("ja");
+ let rows = super::entries(&h.app, 0, "sketches");
+ assert_eq!(rows.iter().map(|r| r.label.as_str()).collect::<Vec<_>>(), ["スケッチ1 (編集中)"]);
+}
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index 17dee33c70..3e232824ea 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -5331,13 +5331,16 @@ fn overlays(app: &SolveApp, painter: &egui::Painter, proj: &Proj) {
loose_end_markers(sk, &ss.ends, &ss.plane, painter, proj, &v);
// Sketch status.
if let Some(r) = app.viewport.layout.as_ref().map(|l| l.content) {
- let msg = if !ss.report.ok() {
- format!("{} — constraints conflict", ss.name)
+ let status = if !ss.report.ok() {
+ crate::i18n::tr("sketch.status_conflict").to_string()
} else if ss.report.dof == 0 {
- format!("{} — fully constrained", ss.name)
+ crate::i18n::tr("sketch.status_fully_constrained").to_string()
+ } else if ss.report.dof == 1 {
+ crate::i18n::tr("ui.1_degree_of_freedom").to_string()
} else {
- format!("{} — {} degrees of freedom", ss.name, ss.report.dof)
+ crate::i18n::format("sketch.degrees_of_freedom", &[("count", &ss.report.dof.to_string())])
};
+ let msg = format!("{} — {status}", crate::i18n::tr_name(&ss.name));
let c = if ss.report.ok() { v.sketch_accent } else { v.error };
painter.text(pos2(r.left() + 12.0, r.top() + 12.0), Align2::LEFT_TOP, msg, FontId::proportional(t.font_button), c);
}