| 1 | pub use app_base::ui_locale::{tr, tr_args}; |
| 2 | |
| 3 | #[cfg(test)] |
| 4 | mod tests { |
| 5 | use std::sync::{Mutex, MutexGuard}; |
| 6 | |
| 7 | use app_base::ui_locale::{apply_locale, tr}; |
| 8 | |
| 9 | fn locale_test_lock() -> MutexGuard<'static, ()> { |
| 10 | static LOCK: Mutex<()> = Mutex::new(()); |
| 11 | LOCK.lock().unwrap_or_else(|error| error.into_inner()) |
| 12 | } |
| 13 | |
| 14 | #[test] |
| 15 | fn ui_locale_settings_common_actions() { |
| 16 | let _guard = locale_test_lock(); |
| 17 | apply_locale("de"); |
| 18 | assert_eq!(tr("common.cancel"), "Abbrechen"); |
| 19 | apply_locale("en"); |
| 20 | assert_eq!(tr("settings.nav.general"), "General"); |
| 21 | } |
| 22 | |
| 23 | #[test] |
| 24 | fn ui_locale_chrome_rail_and_nav_keys() { |
| 25 | let _guard = locale_test_lock(); |
| 26 | apply_locale("en"); |
| 27 | assert_eq!(tr("rail.activity"), "Activity"); |
| 28 | assert_eq!(tr("rail.chat"), "Chat"); |
| 29 | assert_eq!( |
| 30 | tr("settings.nav.notifications"), |
| 31 | "Notifications and activity" |
| 32 | ); |
| 33 | apply_locale("de"); |
| 34 | assert_eq!(tr("rail.calendar"), "Kalender"); |
| 35 | assert_eq!(tr("common.save"), "Speichern"); |
| 36 | } |
| 37 | |
| 38 | #[test] |
| 39 | fn ui_locale_calls_page_keys_resolve_in_de() { |
| 40 | let _guard = locale_test_lock(); |
| 41 | apply_locale("de"); |
| 42 | assert_eq!(tr("calls.page.title"), "Anrufe"); |
| 43 | assert_eq!(tr("auth.sign_in"), "Anmelden"); |
| 44 | } |
| 45 | |
| 46 | #[test] |
| 47 | fn ui_locale_chat_sidebar_and_filters_in_de() { |
| 48 | let _guard = locale_test_lock(); |
| 49 | apply_locale("de"); |
| 50 | assert_eq!(tr("sidebar.pinned"), "Angepinnt"); |
| 51 | assert_eq!(tr("sidebar.filter.no_matches"), "Keine Treffer gefunden."); |
| 52 | assert_eq!(tr("sidebar.pill.meetings"), "Besprechungschats"); |
| 53 | } |
| 54 | |
| 55 | #[test] |
| 56 | fn ui_locale_call_chrome_in_de() { |
| 57 | let _guard = locale_test_lock(); |
| 58 | apply_locale("de"); |
| 59 | assert_eq!(tr("calls.chrome.stop_sharing"), "Freigabe beenden"); |
| 60 | assert_eq!(tr("calls.prejoin.join_now"), "Jetzt beitreten"); |
| 61 | } |
| 62 | |
| 63 | #[test] |
| 64 | fn ui_locale_calendar_meeting_dialog_in_de() { |
| 65 | let _guard = locale_test_lock(); |
| 66 | apply_locale("de"); |
| 67 | assert_eq!(tr("calls.meeting.new_title"), "Neue Besprechung"); |
| 68 | assert_eq!( |
| 69 | tr("calls.meeting.teams_link_added"), |
| 70 | "Teams-Besprechungslink wird hinzugefügt" |
| 71 | ); |
| 72 | } |
| 73 | |
| 74 | #[test] |
| 75 | |
| 76 | #[test] |
| 77 | fn ui_locale_settings_help_keys() { |
| 78 | let _guard = locale_test_lock(); |
| 79 | apply_locale("en"); |
| 80 | assert_eq!(tr("settings.nav.help"), "Help"); |
| 81 | assert_eq!(tr("settings.help.create_bundle_button"), "Create"); |
| 82 | assert_eq!(tr("settings.help.logs_path"), "Logs root"); |
| 83 | assert_eq!(tr("settings.help.bundles_path"), "Support packages"); |
| 84 | assert_eq!(tr("settings.help.packages_empty"), "No support packages yet"); |
| 85 | assert_eq!(tr("settings.help.copy_path_tooltip"), "Copy path"); |
| 86 | assert_eq!(tr("settings.help.debug_logging"), "Debug logging"); |
| 87 | apply_locale("de"); |
| 88 | assert_eq!(tr("settings.nav.help"), "Hilfe"); |
| 89 | assert_eq!(tr("settings.help.create_bundle_button"), "Erstellen"); |
| 90 | assert_eq!(tr("settings.help.logs_path"), "Log-Root"); |
| 91 | assert_eq!(tr("settings.help.bundles_path"), "Support-Pakete"); |
| 92 | assert_eq!(tr("settings.help.packages_empty"), "Noch keine Support-Pakete"); |
| 93 | assert_eq!(tr("settings.help.copy_path_tooltip"), "Pfad kopieren"); |
| 94 | assert_eq!(tr("settings.help.debug_logging"), "Debug-Protokollierung"); |
| 95 | assert!(tr("settings.help.detail").contains("Support-Paket")); |
| 96 | } |
| 97 | |
| 98 | fn ui_locale_auth_splash_keys() { |
| 99 | let _guard = locale_test_lock(); |
| 100 | apply_locale("en"); |
| 101 | assert_eq!( |
| 102 | tr("auth.splash.opening_browser"), |
| 103 | "Opening the browser for sign-in…" |
| 104 | ); |
| 105 | apply_locale("de"); |
| 106 | assert!(tr("auth.splash.awaiting_browser").contains("Browser")); |
| 107 | } |
| 108 | } |