* claim: #4370 * fix(ui): translate history tooltips and feature status
This commit is contained in:
1 parent
2ec11cfc3a
commit
b1bbca97ef
3 files changed
+86
-4
No files matched your search
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"en": {
|
||||
"timeline.delete_folders_tip": "Keep their features and nested folders in the history",
|
||||
"timeline.feature_error": "Error: {message}",
|
||||
"timeline.feature_warning": "Warning: {message}"
|
||||
},
|
||||
"es": {
|
||||
"timeline.delete_folders_tip": "Conservar sus operaciones y carpetas anidadas en el historial",
|
||||
"timeline.feature_error": "Error: {message}",
|
||||
"timeline.feature_warning": "Advertencia: {message}",
|
||||
"ui.history_marker_tip": "Marcador del historial: arrastra para retroceder el modelo; las nuevas operaciones se insertan aquí"
|
||||
},
|
||||
"ja": {
|
||||
"timeline.delete_folders_tip": "フィーチャーと入れ子のフォルダーを履歴に残します",
|
||||
"timeline.feature_error": "エラー: {message}",
|
||||
"timeline.feature_warning": "警告: {message}"
|
||||
},
|
||||
"zh": {
|
||||
"timeline.delete_folders_tip": "在历史记录中保留其中的特征和嵌套文件夹",
|
||||
"timeline.feature_error": "错误:{message}",
|
||||
"timeline.feature_warning": "警告:{message}"
|
||||
}
|
||||
}
|
||||
@@ -296,10 +296,12 @@ 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: {}", crate::i18n::tr_diagnostic(error)));
|
||||
text.push('\n');
|
||||
text.push_str(&crate::i18n::format("timeline.feature_error", &[("message", &crate::i18n::tr_diagnostic(error))]));
|
||||
}
|
||||
if let Some(warning) = warning {
|
||||
text.push_str(&format!("\nWarning: {warning}"));
|
||||
text.push('\n');
|
||||
text.push_str(&crate::i18n::format("timeline.feature_warning", &[("message", &crate::i18n::tr_diagnostic(warning))]));
|
||||
}
|
||||
text
|
||||
}
|
||||
@@ -632,7 +634,7 @@ fn timeline_contents(app: &mut SolveApp, ui: &mut egui::Ui, floating: bool) {
|
||||
ui.ctx().set_cursor_icon(egui::CursorIcon::Grab);
|
||||
}
|
||||
crate::ui_kit::history_marker(&p, mr, false, accent);
|
||||
resp.on_hover_text("History marker: drag to roll the model back; new features go here");
|
||||
resp.on_hover_text(crate::i18n::tr("ui.history_marker_tip"));
|
||||
}
|
||||
let content_end = crate::dialogs_assembly::timeline_joints(app, ui, &p, end + 10.0, r);
|
||||
// The scroll range follows the drawn content (the buttons don't take layout space themselves).
|
||||
@@ -721,6 +723,45 @@ mod tests {
|
||||
|
||||
use crate::scenario::Harness;
|
||||
|
||||
#[test]
|
||||
fn history_status_translates_prefixes_and_both_diagnostics() {
|
||||
let diagnostic = "there is no body to cut or intersect in component 'Mount'; the tool may overlap 'Plate' in component 'Base' — activate that component or pick the body as a target";
|
||||
let _language = crate::i18n::scope("ja");
|
||||
let translated = crate::i18n::tr_diagnostic(diagnostic);
|
||||
assert_ne!(translated, diagnostic);
|
||||
assert_eq!(
|
||||
super::status_text("My feature", "ExtrudeFeature", Some(diagnostic), Some(diagnostic)),
|
||||
format!("My feature (ExtrudeFeature)\nエラー: {translated}\n警告: {translated}")
|
||||
);
|
||||
assert_eq!(super::status_text("My feature", "ExtrudeFeature", None, None), "My feature (ExtrudeFeature)");
|
||||
// Unknown diagnostics remain intact, including names and measured values.
|
||||
assert_eq!(
|
||||
super::status_text("My feature", "ExtrudeFeature", None, Some("Custom part: 1.25 mm")),
|
||||
"My feature (ExtrudeFeature)\n警告: Custom part: 1.25 mm"
|
||||
);
|
||||
let _english = crate::i18n::scope("en");
|
||||
assert_eq!(super::status_text("Box", "BoxFeature", Some("error"), Some("warning")), "Box (BoxFeature)\nError: error\nWarning: warning");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn history_marker_tooltip_uses_the_language_in_both_layouts() {
|
||||
for left in [false, true] {
|
||||
let mut h = Harness::new();
|
||||
h.app.preferences.language = "ja".into();
|
||||
h.app.preferences.timeline_left = left;
|
||||
h.app.run("sketch.create", json!({"plane": "XY"})).unwrap();
|
||||
h.app.run("sketch.finish", json!({})).unwrap();
|
||||
h.frames(4);
|
||||
let marker = crate::scenario::rect_of("history:marker").unwrap().center();
|
||||
h.call("ui.move", json!({"x": marker.x, "y": marker.y}));
|
||||
h.frames(90);
|
||||
let expected = crate::i18n::Locale::for_language("ja").text("ui.history_marker_tip");
|
||||
let output = egui::FullOutput { shapes: h.shapes.clone(), ..Default::default() };
|
||||
let texts: Vec<_> = crate::test_support::text_shapes(&output).map(|t| t.galley.text()).collect();
|
||||
assert!(texts.contains(&expected), "left={left}: {texts:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn construction_history_matches_the_tool_that_created_it() {
|
||||
use solidcraft_engine::doc::{
|
||||
|
||||
@@ -632,7 +632,7 @@ fn selection_actions(app: &mut SolveApp, ui: &mut egui::Ui, groups: &[solidcraft
|
||||
ui.separator();
|
||||
}
|
||||
if crate::context_menu::button(ui, "Delete Selected Folders", "delete")
|
||||
.on_hover_text("Keep their features and nested folders in the history")
|
||||
.on_hover_text(crate::i18n::tr("timeline.delete_folders_tip"))
|
||||
.clicked()
|
||||
{
|
||||
let ids = app.tree.picked_timeline_groups.clone();
|
||||
@@ -1242,6 +1242,24 @@ mod tests {
|
||||
use super::*;
|
||||
use crate::scenario::{Harness, handle_at};
|
||||
|
||||
#[test]
|
||||
fn history_folder_delete_tooltip_uses_the_language() {
|
||||
let mut h = Harness::new();
|
||||
h.app.preferences.timeline_left = true;
|
||||
h.app.preferences.language = "ja".into();
|
||||
h.app.run("timeline.group", json!({"name": "My folder"})).unwrap();
|
||||
h.frames(4);
|
||||
h.step(&json!({"click": {"handle": "timeline-folder:My folder"}, "button": "right"})).unwrap();
|
||||
let label = crate::i18n::Locale::for_language("ja").label("Delete Selected Folders");
|
||||
let [x, y] = h.widget(label).unwrap();
|
||||
h.call("ui.move", json!({"x": x, "y": y}));
|
||||
h.frames(90);
|
||||
let output = egui::FullOutput { shapes: h.shapes.clone(), ..Default::default() };
|
||||
let texts: Vec<_> = crate::test_support::text_shapes(&output).map(|t| t.galley.text()).collect();
|
||||
assert!(texts.contains(&"フィーチャーと入れ子のフォルダーを履歴に残します"), "{texts:?}");
|
||||
assert_eq!(h.app.session.doc.timeline_groups.len(), 1, "hovering does not delete the folder");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn docking_previews_match_all_three_destinations_and_stacked_collapse_shares_height() {
|
||||
for mode in [crate::shell::LayoutMode::Floating, crate::shell::LayoutMode::Docked] {
|
||||
|
||||
Reference in new issue
Block a user