From 87c9a37663a0e119aac24210fdd50005d62f9dcd Mon Sep 17 00:00:00 2001 From: raykholo Date: Sun, 25 Oct 2026 18:42:50 +0000 Subject: [PATCH] Cut and Intersect say which component holds the body they missed (#4639) (#4641) --- .../pending/empty-boolean-component.json | 11 ++ crates/doc/src/eval.rs | 102 ++++++++++++++---- crates/doc/src/eval_more.rs | 16 +-- crates/doc/src/eval_surface.rs | 2 +- crates/doc/src/tests.rs | 50 +++++++++ crates/ui-egui/src/dialogs.rs | 2 +- crates/ui-egui/src/i18n.rs | 34 ++++++ crates/ui-egui/src/lib.rs | 2 +- crates/ui-egui/src/timeline.rs | 2 +- 9 files changed, 188 insertions(+), 33 deletions(-) create mode 100644 assets/locales/pending/empty-boolean-component.json diff --git a/assets/locales/pending/empty-boolean-component.json b/assets/locales/pending/empty-boolean-component.json new file mode 100644 index 000000000..8dd2f070c --- /dev/null +++ b/assets/locales/pending/empty-boolean-component.json @@ -0,0 +1,11 @@ +{ + "en": { + "diagnostic.empty_boolean_component": "there is no body to cut or intersect in component '{component}'; the tool may overlap '{body}' in component '{other}' — activate that component or pick the body as a target" + }, + "ja": { + "diagnostic.empty_boolean_component": "コンポーネント '{component}' に切り取りまたは交差の対象となるボディがありません。ツールはコンポーネント '{other}' の '{body}' と重なる可能性があります。そのコンポーネントをアクティブにするか、ボディを対象として選択してください" + }, + "zh": { + "diagnostic.empty_boolean_component": "组件 '{component}' 中没有可供切除或求交的实体;工具可能与组件 '{other}' 中的 '{body}' 重叠 — 请激活该组件或选择该实体作为目标" + } +} diff --git a/crates/doc/src/eval.rs b/crates/doc/src/eval.rs index 1731d0607..3f60ccfc9 100644 --- a/crates/doc/src/eval.rs +++ b/crates/doc/src/eval.rs @@ -2601,7 +2601,15 @@ fn intersection_tool_union(tools: Vec) -> Result> { } /// After a cut handled some sheet bodies as flat machining, apply it to the other targets. -fn apply_beside_sheet_cut(st: &mut ModelState, f: &Feature, tools: Vec, op: Operation, targets: &[String], handled: &[String]) -> Result<()> { +fn apply_beside_sheet_cut( + doc: &Document, + st: &mut ModelState, + f: &Feature, + tools: Vec, + op: Operation, + targets: &[String], + handled: &[String], +) -> Result<()> { let effective = if targets.is_empty() { &f.participants } else { targets }; let all = effective.len() == 1 && effective.first().is_some_and(|t| t == "*"); let rest: Vec = st @@ -2616,7 +2624,7 @@ fn apply_beside_sheet_cut(st: &mut ModelState, f: &Feature, tools: Vec, if rest.is_empty() { return Ok(()); } - apply_traced(st, f, tools, op, &rest) + apply_traced(doc, st, f, tools, op, &rest) } /// Only one target meets every separated tool. A tool with no contact must retain @@ -2642,8 +2650,8 @@ fn common_join_target(state: &ModelState, indices: &[usize], tools: &[Traced]) - Ok(common.filter(|index| contacts.iter().all(|contact| *contact == Some(*index)))) } -fn apply_op(state: &mut ModelState, f: &Feature, tools: Vec, op: Operation, targets: &[String]) -> Result<()> { - apply_traced(state, f, tools.into_iter().map(Traced::unnamed).collect(), op, targets) +fn apply_op(doc: &Document, state: &mut ModelState, f: &Feature, tools: Vec, op: Operation, targets: &[String]) -> Result<()> { + apply_traced(doc, state, f, tools.into_iter().map(Traced::unnamed).collect(), op, targets) } /// Many cut tools clear of each other (a pattern's copies, the circles of a vent field in one @@ -2688,8 +2696,60 @@ pub(crate) fn boolean_scope(state: &ModelState, f: &Feature, targets: &[String]) (!all && !effective.is_empty(), names) } +/// Suggest one nearby body without changing the default component scope or running a boolean. +fn empty_boolean_targets(doc: &Document, state: &ModelState, f: &Feature, tools: &[Traced], default_targets: bool) -> DocError { + let plain = "there is no body to cut or intersect"; + if !default_targets { + return DocError::Invalid(plain.into()); + } + let component_name = |id| { + if id == 0 { + doc.name.clone() + } else { + doc.components.iter().take(10_000).find(|c| c.id == id).map(|c| c.name.clone()).unwrap_or_else(|| format!("Component{id}")) + } + }; + let tool_bounds: Vec<_> = tools.iter().take(64).map(|t| t.body.outline_bounds()).collect(); + let frame = doc.component_transform(f.component); + let Some(inverse) = crate::mat_inverse(&frame) else { return DocError::Invalid(plain.into()) }; + // Named by the component the Browser shows the body in; one shown in the feature's own + // component has no other component to point at. + let others = state + .bodies + .iter() + .take(256) + .map(|b| (b, doc.model_body_component(b))) + .filter(|(b, owner)| b.component != f.component && *owner != f.component); + for (body, owner) in others { + // Compare in the feature's frame, including component placements and body offsets. + let world = body_world(doc, body); + let relative = crate::mat_mul(&inverse, &world); + let bounds = body.outline_bounds(); + if bounds.is_empty() || !bounds.min.is_finite() || !bounds.max.is_finite() { + continue; + } + let mut placed = solidcraft_geom::Aabb3::EMPTY; + for x in [bounds.min.x, bounds.max.x] { + for y in [bounds.min.y, bounds.max.y] { + for z in [bounds.min.z, bounds.max.z] { + placed.add(crate::apply_point(&relative, Vec3::new(x, y, z))); + } + } + } + if tool_bounds.iter().any(|b| !b.is_empty() && b.min.is_finite() && b.max.is_finite() && b.meets(&placed)) { + let own = component_name(f.component); + let other = component_name(owner); + let name = &body.name; + return DocError::Invalid(format!( + "{plain} in component '{own}'; the tool may overlap '{name}' in component '{other}' — activate that component or pick the body as a target" + )); + } + } + DocError::Invalid(plain.into()) +} + /// [`apply_op`] with tools whose lineage is known: the bodies it makes or changes keep theirs. -fn apply_traced(state: &mut ModelState, f: &Feature, tools: Vec, op: Operation, targets: &[String]) -> Result<()> { +fn apply_traced(doc: &Document, state: &mut ModelState, f: &Feature, tools: Vec, op: Operation, targets: &[String]) -> Result<()> { let tools = if op == Operation::Intersect { intersection_tool_union(tools)? } else { tools }; // Participants: the feature's own targets, else its explicit participants, else the bodies // of its component (and what it made itself): other components are left alone. @@ -2709,7 +2769,7 @@ fn apply_traced(state: &mut ModelState, f: &Feature, tools: Vec, op: Ope }; if op == Operation::NewBody || target_idx.is_empty() { if op == Operation::Cut || op == Operation::Intersect { - return Err(DocError::Invalid("there is no body to cut or intersect".into())); + return Err(empty_boolean_targets(doc, state, f, &tools, targets.is_empty())); } for (k, t) in tools.into_iter().enumerate() { let name = new_name(state, f, k); @@ -2755,7 +2815,7 @@ fn apply_traced(state: &mut ModelState, f: &Feature, tools: Vec, op: Ope let mut batched = state.clone(); // Preserve the original participants. For Join, the compound's larger // size must not expand the contact tolerance and absorb a nearby body. - if apply_traced(&mut batched, f, vec![Traced::step(compound, &tools.iter().collect::>())], op, &names).is_ok() { + if apply_traced(doc, &mut batched, f, vec![Traced::step(compound, &tools.iter().collect::>())], op, &names).is_ok() { *state = batched; return Ok(()); } @@ -6301,12 +6361,12 @@ fn replay( } // New bodies from a pattern join their source when they touch it (as one feature would). if f.body_names.is_empty() { - apply_traced(st, f, copies, op, &targets)?; + apply_traced(doc, st, f, copies, op, &targets)?; } else { let start = st.bodies.iter().filter(|b| b.feature == f.id).count(); let mut named = f.clone(); named.body_names = f.body_names.iter().skip(start).cloned().collect(); - apply_traced(st, &named, copies, op, &targets)?; + apply_traced(doc, st, &named, copies, op, &targets)?; } } if missed > 0 { @@ -6787,10 +6847,10 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: let bodies: Vec = tools.iter().map(|t| t.body.clone()).collect(); let handled = more::sheet_cut(f, st, &bodies, &crate::plain(targets), constructor.as_ref(), warning)?; if !handled.is_empty() { - return apply_beside_sheet_cut(st, f, tools, *operation, &crate::plain(targets), &handled); + return apply_beside_sheet_cut(doc, st, f, tools, *operation, &crate::plain(targets), &handled); } } - apply_traced(st, f, tools, *operation, &crate::plain(targets)) + apply_traced(doc, st, f, tools, *operation, &crate::plain(targets)) } FeatureKind::Hole { thread, thread_depth, diameter, .. } => { let thread_depth = thread_depth.as_ref().map(|d| val(vals, d, Kind::Length)).transpose()?; @@ -6805,9 +6865,9 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: let handled = sheet_hole_cut(st, f, &tools, warning)?; let tools: Vec = tools.into_iter().map(|(tool, _)| tool).collect(); if handled.is_empty() { - apply_traced(st, f, tools, Operation::Cut, &[])?; + apply_traced(doc, st, f, tools, Operation::Cut, &[])?; } else { - apply_beside_sheet_cut(st, f, tools, Operation::Cut, &[], &handled)?; + apply_beside_sheet_cut(doc, st, f, tools, Operation::Cut, &[], &handled)?; } if let Some(d) = thread { // Find the bore beyond any entry recess, including shallow and through holes. @@ -7014,7 +7074,7 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: if *remove_tools { st.bodies.retain(|b| !tools.iter().any(|t| *t == b.name)); } - apply_traced(st, f, made, *operation, &[]) + apply_traced(doc, st, f, made, *operation, &[]) } FeatureKind::SplitFace { faces, body, plane, tool, sketch } => { let i = body_at(st, body, &crate::plain(faces))?; @@ -7247,9 +7307,9 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: let handled = more::sheet_primitive_cut(f, st, &b, more::PrimitivePrism::Box { lo: corner, hi: corner + s }, *operation, false, warning)?; let tools = vec![crate::lineage::box_tool(b)]; if !handled.is_empty() { - return apply_beside_sheet_cut(st, f, tools, *operation, &[], &handled); + return apply_beside_sheet_cut(doc, st, f, tools, *operation, &[], &handled); } - apply_traced(st, f, tools, *operation, &[]) + apply_traced(doc, st, f, tools, *operation, &[]) } FeatureKind::Cylinder { base, axis, radius, height, operation } => { let (base, radius, height) = (point(vals, base)?, val(vals, radius, Kind::Length)?, val(vals, height, Kind::Length)?); @@ -7259,17 +7319,17 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: let handled = more::sheet_primitive_cut(f, st, &b, prism, *operation, false, warning)?; let tools = vec![crate::lineage::cylinder_tool(b)]; if !handled.is_empty() { - return apply_beside_sheet_cut(st, f, tools, *operation, &[], &handled); + return apply_beside_sheet_cut(doc, st, f, tools, *operation, &[], &handled); } - apply_traced(st, f, tools, *operation, &[]) + apply_traced(doc, st, f, tools, *operation, &[]) } FeatureKind::Sphere { center, radius, operation } => { let b = kernel::sphere(point(vals, center)?, val(vals, radius, Kind::Length)?)?; - apply_op(st, f, vec![b], *operation, &[]) + apply_op(doc, st, f, vec![b], *operation, &[]) } FeatureKind::Torus { center, major, minor, operation } => { let b = kernel::torus(point(vals, center)?, val(vals, major, Kind::Length)?, val(vals, minor, Kind::Length)?)?; - apply_op(st, f, vec![b], *operation, &[]) + apply_op(doc, st, f, vec![b], *operation, &[]) } FeatureKind::Combine { target, tools, operation, keep_tools } => { if tools.iter().any(|t| t == target) { @@ -7317,7 +7377,7 @@ fn eval_feature(doc: &Document, vals: &BTreeMap, f: &Feature, st: return Ok(()); // the pieces were all joined back into the body they are part of } let op = if *operation == Operation::NewBody { Operation::Join } else { *operation }; - apply_traced(st, f, tb, op, std::slice::from_ref(&target.0))?; + apply_traced(doc, st, f, tb, op, std::slice::from_ref(&target.0))?; if !keep_tools { st.bodies.retain(|b| !tools.iter().any(|t| *t == b.name)); } diff --git a/crates/doc/src/eval_more.rs b/crates/doc/src/eval_more.rs index 787f5e371..873048982 100644 --- a/crates/doc/src/eval_more.rs +++ b/crates/doc/src/eval_more.rs @@ -67,11 +67,11 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap, f: &Feature, if st.bodies.is_empty() { return Err(DocError::Invalid("there is no body to emboss".into())); } - apply_op(st, f, tools, if *deboss { Operation::Cut } else { Operation::Join }, &crate::plain(targets)) + apply_op(doc, st, f, tools, if *deboss { Operation::Cut } else { Operation::Join }, &crate::plain(targets)) } FeatureKind::Rib { .. } => { let tools = rib_tools(vals, st, f, None)?; - apply_op(st, f, tools, Operation::Join, &[]) + apply_op(doc, st, f, tools, Operation::Join, &[]) } FeatureKind::ReplaceFace { faces, target, body } => { let tp = doc.resolve_plane_in(vals, target, 0, Some(st))?; @@ -1889,7 +1889,7 @@ pub(super) fn plastic_eval(doc: &Document, vals: &BTreeMap, f: &F tools.extend(kernel::extrude(&rp, &[rect], -delta, hr)?.into_iter().map(|b| crate::lineage::part_tool(b, &format!("rib{k}")))); } } - apply_traced(st, f, tools, Operation::Join, std::slice::from_ref(&target))?; + apply_traced(doc, st, f, tools, Operation::Join, std::slice::from_ref(&target))?; // The root fillet: rounds the circle where the post meets the face. if rf > 1e-9 { let i = st.bodies.iter().position(|b| b.name == target).ok_or_else(|| DocError::Invalid("boss body".into()))?; @@ -1913,7 +1913,7 @@ pub(super) fn plastic_eval(doc: &Document, vals: &BTreeMap, f: &F let hp = Plane::new(position.0, x, z.cross(x)).ok_or_else(|| DocError::Invalid("hole frame".into()))?; let tool = kernel::extrude(&hp, &[Region2 { outer: Loop2::circle(Vec2::ZERO, rh), holes: Vec::new() }], h - depth, h + delta)?; let tool = tool.into_iter().map(|b| crate::lineage::part_tool(b, "hole")).collect(); - apply_traced(st, f, tool, Operation::Cut, std::slice::from_ref(&target))?; + apply_traced(doc, st, f, tool, Operation::Cut, std::slice::from_ref(&target))?; } Ok(()) } @@ -1999,10 +1999,10 @@ pub(super) fn plastic_eval(doc: &Document, vals: &BTreeMap, f: &F let delta = (h * 0.05).clamp(1e-3, 0.5); if *groove { let tool = kernel::extrude(&plane, &[band], -(h + g), delta)?.into_iter().map(|b| crate::lineage::part_tool(b, "groove")).collect(); - apply_traced(st, f, tool, Operation::Cut, std::slice::from_ref(&target)) + apply_traced(doc, st, f, tool, Operation::Cut, std::slice::from_ref(&target)) } else { let tool = kernel::extrude(&plane, &[band], -delta, h)?.into_iter().map(|b| crate::lineage::part_tool(b, "lip")).collect(); - apply_traced(st, f, tool, Operation::Join, std::slice::from_ref(&target)) + apply_traced(doc, st, f, tool, Operation::Join, std::slice::from_ref(&target)) } } FeatureKind::SnapFit { position, direction, hook, length, thickness, width, catch_depth, catch_length, body } => { @@ -2028,7 +2028,7 @@ pub(super) fn plastic_eval(doc: &Document, vals: &BTreeMap, f: &F let (lo, hi) = if sgn > 0.0 { (0.0, w) } else { (-w, 0.0) }; let tool = kernel::extrude(&pl, &[Region2 { outer: lp, holes: Vec::new() }], lo, hi)?; let tool = tool.into_iter().map(|b| crate::lineage::part_tool(b, "arm")).collect(); - apply_traced(st, f, tool, Operation::Join, std::slice::from_ref(&target)) + apply_traced(doc, st, f, tool, Operation::Join, std::slice::from_ref(&target)) } FeatureKind::Rest { position, direction, along, width, length, height, draft, thickness, body } => { let target = body_under(st, body, position.0)?; @@ -2079,7 +2079,7 @@ pub(super) fn plastic_eval(doc: &Document, vals: &BTreeMap, f: &F kernel::extrude(&base, &[region], 0.0, h + delta)? }; let tool = tool.into_iter().map(|b| crate::lineage::part_tool(b, "rest")).collect(); - apply_traced(st, f, tool, Operation::Join, std::slice::from_ref(&target)) + apply_traced(doc, st, f, tool, Operation::Join, std::slice::from_ref(&target)) } _ => Err(DocError::Invalid(format!("{} is not a plastic feature", f.name))), } diff --git a/crates/doc/src/eval_surface.rs b/crates/doc/src/eval_surface.rs index f1635d45d..085243ad3 100644 --- a/crates/doc/src/eval_surface.rs +++ b/crates/doc/src/eval_surface.rs @@ -65,7 +65,7 @@ pub(super) fn eval(doc: &Document, vals: &BTreeMap, f: &Feature, if tools.is_empty() { return Err(DocError::Invalid("pick the surfaces to thicken".into())); } - apply_op(st, f, tools, *operation, &crate::plain(targets)) + apply_op(doc, st, f, tools, *operation, &crate::plain(targets)) } FeatureKind::SurfaceTrim { body, plane, tool, keep, keep_more, curves, with, keep_with, stitch, extend } => { let i = st.bodies.iter().position(|b| &b.name == body).ok_or_else(|| DocError::Unknown(format!("body `{body}`")))?; diff --git a/crates/doc/src/tests.rs b/crates/doc/src/tests.rs index 3e5042c6e..5acee029b 100644 --- a/crates/doc/src/tests.rs +++ b/crates/doc/src/tests.rs @@ -492,3 +492,53 @@ fn new_names_take_the_first_free_number() { let next = sketch(&mut doc); assert_eq!(name(&doc, next), names[0], "the first freed number is taken again"); } + +#[test] +fn empty_boolean_targets_name_overlapping_component() { + for (operation, offset) in [(Operation::Cut, 0.0), (Operation::Intersect, 0.0), (Operation::Cut, 40.0)] { + let (mut doc, sketch) = plate_doc(); + let imported = doc.add_component(Some("Imported STEP"), 0).unwrap(); + let part = doc.add_component(Some("Part1"), 0).unwrap(); + doc.features.last_mut().unwrap().component = imported; + doc.feature_mut(sketch).unwrap().component = imported; + doc.occurrences.iter_mut().find(|o| o.component == imported).unwrap().transform[2][3] = offset; + let mut kind = doc.features.last().unwrap().kind.clone(); + if let FeatureKind::Extrude { operation: op, .. } = &mut kind { + *op = operation; + } + let cut = doc.add_feature(kind, None).unwrap(); + doc.feature_mut(cut).unwrap().component = part; + let mut model = Model::new(); + model.evaluate(&doc); + let error = model.result(cut).unwrap().error.as_deref().unwrap(); + assert!(error.contains("component 'Part1'"), "offset {offset}: {error}"); + assert!(error.contains("'Body1' in component 'Imported STEP'"), "offset {offset}: {error}"); + assert!(error.contains("activate that component or pick the body as a target"), "offset {offset}: {error}"); + assert_eq!(model.state().bodies.len(), 1); + assert!(rel(measure(&model.state().bodies[0].body).unwrap().volume, 24000.0) < 1e-9); + } +} + +#[test] +fn empty_boolean_targets_without_overlap_keep_plain_message() { + for operation in [Operation::Cut, Operation::Intersect] { + let (mut doc, _) = plate_doc(); + let part = doc.add_component(Some("Part1"), 0).unwrap(); + let cut = doc + .add_feature( + FeatureKind::Box { + corner: point_expr(Vec3::new(100.0, 100.0, 100.0)), + length: "1".into(), + width: "1".into(), + height: "1".into(), + operation, + }, + None, + ) + .unwrap(); + doc.feature_mut(cut).unwrap().component = part; + let mut model = Model::new(); + model.evaluate(&doc); + assert_eq!(model.result(cut).unwrap().error.as_deref(), Some("there is no body to cut or intersect")); + } +} diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index d44c598b9..c77944a36 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -2270,7 +2270,7 @@ fn error_rows(app: &mut SolveApp, ctx: &egui::Context, d: &mut Dialog, ui: &mut /// message is in the catalogs. fn shown_error(error: &str) -> String { let msg = error.strip_prefix("invalid parameters for `").and_then(|rest| rest.split_once("`: ")).map_or(error, |(_, msg)| msg); - crate::i18n::tr_label(msg).to_string() + crate::i18n::tr_diagnostic(crate::i18n::tr_label(msg)) } /// Find the Boundary Fill cells again when the tool bodies changed (keeping the choices of diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 9aecac2df..bdd953d40 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -166,6 +166,22 @@ impl Locale { self.default_name(text).unwrap_or_else(|| text.to_string()) } + /// Evaluation errors stay English for scripts; the empty Cut/Intersect hint that names + /// another component is translated where it is shown. Other text is returned unchanged. + pub fn diagnostic(self, text: &str) -> String { + const PREFIX: &str = "there is no body to cut or intersect in component '"; + if let Some((before, detail)) = text.split_once(PREFIX) + && let Some((component, detail)) = detail.split_once("'; the tool may overlap '") + && let Some((body, detail)) = detail.split_once("' in component '") + && let Some((other, after)) = detail.split_once("' — activate that component or pick the body as a target") + { + let (component, body, other) = (self.given_name(component), self.given_name(body), self.given_name(other)); + let message = self.format("diagnostic.empty_boolean_component", &[("component", &component), ("body", &body), ("other", &other)]); + return format!("{before}{message}{after}"); + } + text.to_string() + } + /// Translate generated browser names and labels, preserving custom names otherwise. pub fn dynamic(self, text: &str) -> String { if let Some(name) = self.default_name(text) { @@ -258,6 +274,9 @@ pub fn tr_dyn(text: &str) -> String { pub fn tr_name(text: &str) -> String { CURRENT.with(|current| current.get().given_name(text)) } +pub fn tr_diagnostic(text: &str) -> String { + CURRENT.with(|current| current.get().diagnostic(text)) +} #[cfg(test)] mod tests { @@ -309,6 +328,21 @@ mod tests { } } + #[test] + fn empty_boolean_component_diagnostic_translates_with_literal_names() { + let message = "solid.extrude: there is no body to cut or intersect in component 'Part {1}'; the tool may overlap 'Bracket' in component 'Imported STEP' — activate that component or pick the body as a target"; + assert_eq!(Locale::for_language("en").diagnostic(message), message); + for (language, prefix) in [("ja", "solid.extrude: コンポーネント"), ("zh", "solid.extrude: 组件")] { + let translated = Locale::for_language(language).diagnostic(message); + assert!(translated.starts_with(prefix), "{translated}"); + for name in ["Part {1}", "Bracket", "Imported STEP"] { + assert!(translated.contains(name), "{translated}"); + } + } + let plain = "there is no body to cut or intersect"; + assert_eq!(Locale::for_language("ja").diagnostic(plain), plain); + } + /// English first, then by id, so adding a locale edits only its own line. #[test] fn locales_are_listed_english_first_then_by_id() { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 54fe90707..bc84b4c3f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1407,7 +1407,7 @@ impl SolveApp { } pub fn set_status(&mut self, s: impl Into, error: bool) { - let (text, at) = (s.into(), now_ms()); + let (text, at) = (i18n::tr_diagnostic(&s.into()), now_ms()); self.messages.push(&text, error, at); self.status = Some((text, at, error)); self.status_undo = false; diff --git a/crates/ui-egui/src/timeline.rs b/crates/ui-egui/src/timeline.rs index d3c70dead..ab1831e1c 100644 --- a/crates/ui-egui/src/timeline.rs +++ b/crates/ui-egui/src/timeline.rs @@ -296,7 +296,7 @@ pub(crate) fn clipboard_buttons(app: &mut SolveApp, ui: &mut egui::Ui, id: u64) pub(crate) fn status_text(name: &str, ty: &str, error: Option<&str>, warning: Option<&str>) -> String { let mut text = format!("{name} ({ty})"); if let Some(error) = error { - text.push_str(&format!("\nError: {error}")); + text.push_str(&format!("\nError: {}", crate::i18n::tr_diagnostic(error))); } if let Some(warning) = warning { text.push_str(&format!("\nWarning: {warning}"));