From 7c1579934c8380ecf2b5d1fd2b69d8cc45158ff8 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Tue, 10 Nov 2026 14:59:09 -0700 Subject: [PATCH] test(ui): App::announce, the status line for each command result, checked for every result in the pseudo-locale (M8) --- src/app.rs | 8 +++++++- src/i18n/tests.rs | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 566559d3..5fd3436c 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1161,6 +1161,13 @@ impl App { self.status_ok(tr!("Restored “{name}”. It isn't saved yet: Save to keep it.", name = name)); return Some(v); } + self.announce(id, &v, selected); + Some(v) + } + + /// What a command's result means for the window: the status line, and the view state a + /// new document resets. `selected` is how many elements were selected before it ran. + pub(crate) fn announce(&mut self, id: &str, v: &Value, selected: usize) { match id { "file.new" | "file.new_sample" | "file.open" => { self.view.fit = true; @@ -1294,7 +1301,6 @@ impl App { } _ => {} } - Some(v) } /// Invokes a command from a menu, shortcut, palette or context menu, asking for a path or diff --git a/src/i18n/tests.rs b/src/i18n/tests.rs index 48e5adc6..cccd3f89 100644 --- a/src/i18n/tests.rs +++ b/src/i18n/tests.rs @@ -584,6 +584,42 @@ fn every_control_can_be_used_in_the_pseudo_locale() { assert!(found.is_empty(), "{} things in plain English after using the controls:\n{}", found.len(), found.join("\n")); } +#[test] +fn status_lines_for_every_result_are_translated() { + // What the status bar says for results a test can't produce for real (saves, exports, + // imports, recovered work, plug-ins), from results shaped as the commands return them. + use serde_json::json; + let (mut app, _ctx) = pseudo_app(|_, _| {}); + let full = json!({ + "saved": "walk.anicraft", "written": "walk.png", "seconds": 1.5, "frames": 3, "columns": 2, "rows": 2, "map": "walk.json", + "kb": 12, "layers": 2, "masks": 1, "elements": 3, "report": "Imported walk.fla.", "copied": 2, "cut": 2, "pasted": 2, + "removed": 2, "cleared": 2, "original_newer": true, "sounds": 1, "name": "beat", "sound": 1, "log": ["Did it."], + "installed": [{"name": "Tint", "version": "1.0"}], "failed": ["bad.wasm: not a plug-in"], "replaced": "Tint 0.9", + "plugin": {"name": "Tint", "version": "1.0"}, "undone": "Move", "redone": "Move", + }); + let bare = json!({}); + let ids = [ + "file.new", "file.open", "file.recover", "file.discard_recovery", "file.save", "file.save_as", "file.import", "file.import_to_library", + "file.export_audio", "file.export_sprite_sheet", "file.export_html", "file.export_lottie", "file.export_png", "file.export_gif", + "sound.delete", "edit.undo", "edit.redo", "edit.delete", "layer.delete", "draw.erase_all", "scene.delete", "scene.new", + "timeline.clear_keyframe", "timeline.copy_frames", "timeline.cut_frames", "timeline.paste_frames", "timeline.remove_frame", + "plugin.run", "plugin.install", "plugin.remove", "plugin.reload", + ]; + let mut plain = Vec::new(); + for id in ids { + for (shape, v) in [("full", &full), ("bare", &bare)] { + app.status = None; + app.announce(id, v, 2); + if let Some(s) = &app.status + && !s.text.chars().any(pseudo::is_accented) + { + plain.push(format!("{id} ({shape}): {:?}", s.text)); + } + } + } + assert!(plain.is_empty(), "status lines in plain English:\n{}", plain.join("\n")); +} + #[test] fn tool_status_lines_are_translated() { // The Eraser's and Eyedropper's results on the sample (on the sun and the hills, and on