From 813e30be69235a6d6490edfbe3a67713912e1bad Mon Sep 17 00:00:00 2001 From: el-j Date: Wed, 28 Oct 2026 10:26:27 +0100 Subject: [PATCH] =?UTF-8?q?i18n:=20fold=20Polish=20=C5=82=20and=20addition?= =?UTF-8?q?al=20Latin=20diacritics=20in=20name=5Fsort=5Fkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/ui-egui/src/i18n.rs | 12 +++++++++--- crates/ui-egui/src/menus/tests.rs | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 47908f33c..92da78873 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -670,11 +670,16 @@ pub fn name_sort_key(name: &str) -> String { .map(|c| match c { 'à'..='å' | 'ā' | 'ă' | 'ą' => 'a', 'ç' | 'ć' | 'č' => 'c', + 'ď' | 'đ' => 'd', 'è'..='ë' | 'ē' | 'ě' | 'ę' | 'ế' | 'ệ' => 'e', - 'ì'..='ï' | 'ī' => 'i', - 'ñ' | 'ń' | 'ň' => 'n', + 'ğ' | 'ģ' => 'g', + 'ì'..='ï' | 'ī' | 'ı' => 'i', + 'ł' | 'ļ' => 'l', + 'ñ' | 'ń' | 'ň' | 'ņ' => 'n', 'ò'..='ö' | 'ø' | 'ő' => 'o', - 'ś' | 'š' => 's', + 'ř' => 'r', + 'ś' | 'š' | 'ş' | 'ș' => 's', + 'ť' | 'ț' | 'ţ' => 't', 'ù'..='ü' | 'ū' | 'ů' | 'ű' => 'u', 'ý' | 'ÿ' => 'y', 'ź' | 'ż' | 'ž' => 'z', @@ -696,5 +701,6 @@ mod picker_order_tests { assert!(keys.windows(2).all(|w| w[0] <= w[1]), "{keys:?}"); assert_eq!(name_sort_key("Čeština"), "cestina"); assert_eq!(name_sort_key("Türkçe"), "turkce"); + assert_eq!(name_sort_key("Łącza"), "lacza"); } } diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index fdf970a6f..efee80d27 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -830,5 +830,19 @@ fn window_menu_panels_are_sorted_alphabetically_in_active_language() { assert!(type_keys.windows(2).all(|w| w[0] <= w[1]), "Type submenu must be alphabetical: {type_labels:?}"); assert_eq!(type_labels, vec!["Caractère", "Glyphes", "OpenType", "Paragraphe", "Styles de caractère", "Styles de paragraphe", "Tabulations",]); + // 4. In Polish: Łącza (Links) folds to L and sorts before Warstwy and Zmienne. + let pl = Lang::from_code("pl").unwrap(); + set_current(pl); + let tree_pl = menu_tree(); + let (_, window_pl) = tree_pl.iter().find(|(t, _)| *t == "Window").unwrap(); + let seps_pl: Vec = window_pl.iter().enumerate().filter(|(_, it)| matches!(it, Item::Sep)).map(|(i, _)| i).collect(); + let panels_pl = &window_pl[seps_pl[1] + 1..seps_pl[2]]; + let pl_labels: Vec = panels_pl.iter().map(|it| item_display(it, pl)).collect(); + let pl_keys: Vec = pl_labels.iter().map(|l| name_sort_key(l)).collect(); + assert!(pl_keys.windows(2).all(|w| w[0] <= w[1]), "Polish panels must be alphabetical: {pl_labels:?}"); + let pos_pl = |name: &str| pl_labels.iter().position(|l| l == name).unwrap_or_else(|| panic!("missing {name} in {pl_labels:?}")); + assert!(pos_pl("Łącza") < pos_pl("Warstwy"), "Łącza before Warstwy"); + assert!(pos_pl("Warstwy") < pos_pl("Zmienne"), "Warstwy before Zmienne"); + set_current(prev); }