Merge PR #1416: Localize Info Overlay mode-change notices

This commit is contained in:
Brandon Thomas committed 2026-10-18 09:19:29 -04:00
commit e6a7501adc
2 files changed
+35 -1

No files matched your search

+34
View File
@@ -4292,6 +4292,40 @@ mod tests {
h.settle(SETTLE);
}
/// #911 (toast labels only): cycling the overlay announces each mode in the UI language.
#[test]
fn info_overlay_toasts_are_painted_in_the_users_language() {
use crate::i18n::Locale;
struct RestoreLanguage(Locale);
impl Drop for RestoreLanguage {
fn drop(&mut self) {
crate::i18n::set_language(self.0);
}
}
let _restore = RestoreLanguage(crate::i18n::language());
let mut h = demo([1000.0, 700.0]);
let t = Duration::from_secs(10);
assert_eq!(h.request("ui.set", json!({"view": "detail", "infoOverlay": "off"}), t)["ok"], true);
for (command, locale) in [("app.language.german", Locale::De), ("app.language.french", Locale::Fr), ("app.language.english", Locale::En)] {
assert_eq!(h.request("engine.execute", json!({"command": command}), t)["ok"], true);
assert_eq!(h.app.ui.language, locale);
assert_eq!(crate::i18n::language(), locale);
for (mode, key) in [("basic", "Info Overlay: File"), ("exposure", "Info Overlay: Exposure"), ("off", "Info Overlay Off")] {
let expected = locale.tr(key);
if locale != Locale::En {
assert_ne!(expected, key, "this locale must translate the tested message");
}
assert_eq!(h.request("ui.key", json!({"key": "i", "cmd": true}), t)["ok"], true);
assert_eq!(serde_json::to_value(h.app.ui.info_overlay).unwrap(), json!(mode));
assert_eq!(h.app.ui.toast.as_ref().expect("overlay toast").0, expected);
h.step();
let painted = h.painted_text();
assert!(painted.iter().any(|text| text == expected), "{painted:?}");
}
}
}
/// A click on the image zooms to the chosen click-zoom ratio (1:1 by default), animating the
/// loupe while rendering once at the final size; Z uses the same ratio; a second click returns to Fit.
#[test]
+1 -1
View File
@@ -705,7 +705,7 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Re
crate::state::InfoOverlay::Basic => "Info Overlay: File",
crate::state::InfoOverlay::Exposure => "Info Overlay: Exposure",
};
app.toast(&ctx, label);
app.toast(&ctx, crate::i18n::tr(label));
Ok(json!({"infoOverlay": app.ui.info_overlay}))
}
"view.chooseLayoutImage" => {