diff --git a/Cargo.lock b/Cargo.lock index 5b426c8f8..c7c81888f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1988,6 +1988,7 @@ dependencies = [ "effectcraft-segment", "effectcraft-text", "effectcraft-time", + "effectcraft-ui-egui", "eframe", "egui", "egui_extras", diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 1576907cb..3c5862594 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -45,7 +45,17 @@ craft-update = { workspace = true } pollster = { workspace = true } sys-locale = { workspace = true } +[features] +# Tests only, never enable in a product: Settings ▸ General ▸ Language ▸ Match System resolves to +# English, so English label lookups pass on any system language (#3244). The self dev-dependency +# below turns it on wherever dev-dependencies are built: this crate's integration tests, its +# examples (`snapshot` shots are deterministic English unless a step sets a language) and +# workspace test builds of the apps (`cargo test --workspace`). +test-support = [] + [dev-dependencies] +# This crate's own integration tests build it with `test-support` (see `[features]`). +effectcraft-ui-egui = { workspace = true, features = ["test-support"] } # Fonts for kittest: the workspace `egui` features are what test roots resolve, but stating them # here documents the requirement (kittest's own dev-dependencies do not propagate to consumers). egui = { workspace = true, features = ["default_fonts", "monochrome_emoji_fonts"] } diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 68e58f842..8ab99ead7 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -84,7 +84,14 @@ pub(crate) fn swedish(app: &EffectcraftApp) -> bool { /// Settings ▸ General ▸ Language ▸ Match System: the operating system's interface language /// where EffectCraft has it, else English (#229), as After Effects installs in the system's /// language. The browser build follows the locales its page passes in ([`set_system_locales`]). +/// +/// Test builds (this crate's unit tests, and its integration tests through the `test-support` +/// feature) resolve Match System to English, so tests that look up English labels pass on any +/// system language (#3244); tests about a translation choose their language explicitly. fn system_language() -> &'static str { + if cfg!(any(test, feature = "test-support")) { + return "en"; + } #[cfg(not(target_arch = "wasm32"))] { static LANGUAGE: std::sync::OnceLock<&'static str> = std::sync::OnceLock::new(); @@ -9169,13 +9176,22 @@ mod tests { } let mut app = EffectcraftApp::new(effectcraft_engine::Session::default()); assert_eq!(app.session.prefs.general.language, "system", "the default"); - assert_eq!(japanese(&app), system_language() == "ja"); - assert_eq!(simplified(&app), system_language() == "zh-hans"); - assert_eq!(traditional(&app), system_language() == "zh-hant"); - assert_eq!(spanish(&app), system_language() == "es"); - assert_eq!(czech(&app), system_language() == "cs"); - assert_eq!(polish(&app), system_language() == "pl"); - assert_eq!(swedish(&app), system_language() == "sv"); + assert_eq!(system_language(), "en", "test builds pin Match System to English (#3244)"); + assert_eq!(language(&app), "en"); + for (flag, name) in [ + (japanese(&app), "ja"), + (simplified(&app), "zh-hans"), + (traditional(&app), "zh-hant"), + (ukrainian(&app), "uk"), + (spanish(&app), "es"), + (brazilian_portuguese(&app), "pt-br"), + (czech(&app), "cs"), + (polish(&app), "pl"), + (georgian(&app), "ka"), + (swedish(&app), "sv"), + ] { + assert!(!flag, "Match System shows {name} in a test build"); + } app.session.execute("prefs.set", json!({"key":"general.language", "value":"ja"})).unwrap(); assert!(japanese(&app)); app.session.execute("prefs.set", json!({"key":"general.language", "value":"zh-hans"})).unwrap();