Files
materialcraft/crates/ui-egui/tests/language_switching.rs
dotCooCoo d23d6c76f1 feat(ui): check for new releases and update the app from inside it
Add Help > Check for updates... (ui.help.checkForUpdates), a check at
startup, the update prompt and result dialog from craft-update, and the
Windows update helper entry point.

A copy of the app downloaded directly was never told about a new version.
Runs driven by --control or MATERIALCRAFT_NO_PREFS skip the startup check.
Shortcuts wait while the prompt or a modal result dialog is open. The
update code builds on desktop only; the web build is unchanged.
2026-11-08 20:25:11 -08:00

39 lines
1.5 KiB
Rust

//! Isolate process-global language switching from tests that construct the UI.
use materialcraft_ui_egui::i18n::{current, is_rtl, set_language, tr, trf};
#[test]
fn language_switching_and_arabic_translations_work() {
set_language("en");
assert_eq!(current().code, "en");
assert_eq!(tr("Properties"), "Properties");
assert!(!is_rtl());
set_language("ar");
assert_eq!(current().code, "ar");
assert_eq!(tr("Properties"), "الخصائص");
assert_eq!(tr("Preferences"), "التفضيلات");
assert_eq!(tr("New graph"), "مخطط جديد");
assert_eq!(tr("Export outputs"), "تصدير المخرجات");
assert_eq!(tr("Welcome to MaterialCraft"), "مرحباً بك في MaterialCraft");
assert!(is_rtl());
// The update menu item and dialogs use the same catalog
assert_eq!(tr("Check for updates..."), "التحقق من وجود تحديثات...");
#[cfg(not(target_arch = "wasm32"))]
{
use materialcraft_ui_egui::updates_ui::translate;
assert_eq!(translate("Cancel", &[]), "إلغاء");
assert_eq!(translate("{app} update", &[("app", "MaterialCraft")]), "MaterialCraft update");
}
// Live formatting
let formatted = trf("Hello {name}", &[("name", &"World")]);
assert_eq!(formatted, "Hello World");
// Fallback for unknown text
assert_eq!(tr("Unknown untranslated string 1234"), "Unknown untranslated string 1234");
// Reset to English
set_language("en");
}