LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
Localize Info Overlay mode notices (#911)
skybluufa715c8c9469
diff --git a/README.md b/README.mdindex 53ec908de..4dba64bec 100644--- a/README.md+++ b/README.md@@ -427,7 +427,7 @@ Without it LightCraft builds and runs the same, but Chinese and Japanese text harepo — the standard for what goes there lives with it: see the [craft-fonts README](https://github.com/storytold/craft-fonts#readme).**Interface language:** **Edit → Language** (English, 简体中文, 繁體中文(台灣), 日本語, Português (Brasil), Español, Deutsch, Русский, Français, Українська, Čeština, ქართული) or **Settings → General →-Language**; the choice applies immediately and persists. See [docs/localization.md](docs/localization.md).+Language**; the choice applies immediately and persists. Info Overlay mode-change toasts use the selected interface language. See [docs/localization.md](docs/localization.md).**Logs:** the desktop app writes its log to standard error and to `logs/lightcraft.log` in its settings folder(Linux `$XDG_CONFIG_HOME/lightcraft/logs/`, by default `~/.config/lightcraft/logs/`; macOSdiff --git a/README.zh-hans.md b/README.zh-hans.mdindex f2d155214..fc9373445 100644--- a/README.zh-hans.md+++ b/README.zh-hans.md@@ -394,7 +394,7 @@ CRAFT_FONTS_DIR=../craft-fonts cargo run --release -p lightcraft本仓库;见 [craftrules `standards/fonts.md`](https://github.com/storytold/craftrules/blob/main/standards/fonts.md)。**界面语言:** **编辑 → 语言**(English、简体中文、繁體中文(台灣)、日本語、Português (Brasil)、Español、Deutsch、Русский、Français)或 **设置 → 一般 →-语言**;选择立即生效并会保留。见 [docs/localization.md](docs/localization.md)。+语言**;选择立即生效并会保留。信息叠加模式切换提示使用所选界面语言。见 [docs/localization.md](docs/localization.md)。**日志:** 桌面应用把日志写到标准错误,以及设置文件夹里的 `logs/lightcraft.log`(Linux `$XDG_CONFIG_HOME/lightcraft/logs/`,默认 `~/.config/lightcraft/logs/`;macOSdiff --git a/crates/ui-egui/src/headless.rs b/crates/ui-egui/src/headless.rsindex 6178990b0..e0888c9bb 100644--- a/crates/ui-egui/src/headless.rs+++ b/crates/ui-egui/src/headless.rs@@ -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]diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rsindex 9fcfc8b9d..cd6829db4 100644--- a/crates/ui-egui/src/menus.rs+++ b/crates/ui-egui/src/menus.rs@@ -705,7 +705,7 @@ pub fn run_ui_command(app: &mut LightcraftApp, id: &str, p: &Value) -> Option<Recrate::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" => {