Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Merge branch 'main' into codex/hungarian-localization

macadminHU5fcd99d4927c
diff --cc crates/ui-egui/src/i18n.rs
index 097cda295,be5f43c97..f885e6929
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@@ -33,9 -32,18 +33,19 @@@ pub const LANGUAGES: &[(&str, &str)] =
("cs", "Čeština"),
("pl", "Polski"),
("ka", "ქართული"),
+ ("hu", "Magyar"),
];
+ /// The interface languages in the order the Preferences picker lists them: English first (the
+ /// source language), then the rest by their own name with accents folded, so Čeština sits under
+ /// C. Names in other scripts follow the Latin ones in code point order: Cyrillic, Arabic,
+ /// Georgian, then the CJK languages.
+ pub fn picker_languages() -> Vec<(&'static str, &'static str)> {
+ let mut rest: Vec<(&str, &str)> = LANGUAGES.iter().copied().filter(|(code, _)| !code.is_empty()).collect();
+ rest.sort_by_cached_key(|(_, name)| name_sort_key(name));
+ std::iter::once(LANGUAGES[0]).chain(rest).collect()
+ }
+
/// English → [German, French, Spanish, Japanese, Simplified Chinese].
const TABLE: &[(&str, [&str; 5])] = &[
// Menus.
@@@ -4788,45 -4713,25 +4809,45 @@@ mod tests
}
}
- /// The tables `tr` reads, as (language, key, translation), context captions included.
- fn entries() -> Vec<(&'static str, &'static str, &'static str)> {
- let mut entries: Vec<_> = LANGUAGE_TABLES.iter().flat_map(|(lang, table)| table.iter().map(|(key, text)| (*lang, *key, *text))).collect();
- for (lang, i) in SHARED_COLUMNS.into_iter().zip(0..) {
- entries.extend(TABLE.iter().filter_map(|(key, row)| row.get(i).map(|text| (lang, *key, *text))));
- entries.extend(CONTEXT.iter().filter_map(|(key, _, row)| row.get(i).map(|text| (lang, *key, *text))));
+ #[test]
+ fn a_column_count_and_a_list_number_read_differently() {
+ for (lang, count, numeral) in [
+ ("hu", "Darabszám:", "Szám:"),
+ ("de", "Anzahl:", "Zahl:"),
+ ("ja", "数:", "番号:"),
+ ("uk", "Кількість:", "Номер:"),
+ ("ar", "العدد:", "الرقم:"),
+ ("fr", "Nombre :", "Numéro:"),
+ ("zh", "数量:", "编号:"),
+ ] {
+ assert_eq!((tr_context(lang, "Number:", "count"), tr(lang, "Number:")), (count, numeral), "{lang}");
+ }
+ assert_eq!(tr_context("en", "Number:", "count"), "Number:");
+ assert_eq!(tr("de", "Gutter:"), "Spaltenabstand:");
+ // The Pages panel menu.
+ for key in [
+ "Insert Pages…",
+ "Move Pages…",
+ "New Parent…",
+ "Override All Parent Page Items",
+ "Remove All Local Overrides",
+ "Detach All Objects from Parent",
+ "Create Alternate Layout…",
+ "Allow Selected Spread to Shuffle",
+ ] {
+ assert_ne!(tr("pt-br", key), key);
}
- entries.extend(CONTEXT_TABLES.iter().flat_map(|(lang, table)| table.iter().map(|(key, _, text)| (*lang, *key, *text))));
- entries
+ assert_ne!(tr("ar", "Apply Parent to Pages"), "Apply Parent to Pages");
}
- /// Every catalog has one row per key and keeps the English placeholders. A string a catalog
- /// doesn't translate shows in English, so a missing or empty row fails nothing here; the
- /// `missing_translations_report` lists them.
+ /// Every catalog: no duplicate or stale keys, no empty translations, and placeholders, padding,
+ /// ellipses and label colons as in English. A string a catalog doesn't translate yet falls back
+ /// to English, so missing translations don't fail here.
#[test]
- fn every_catalog_is_unique_current_and_keeps_placeholders_and_markers() {
- // (language, key, translation) of every catalog, and every catalog's keys by name.
- let mut entries: Vec<(&str, &str, &str)> = Vec::new();
- let mut catalogs: Vec<(&str, HashSet<&str>)> = Vec::new();
+ fn every_catalog_has_unique_keys_and_keeps_placeholders() {
+ for (lang, i) in SHARED_COLUMNS.iter().zip(0..) {
+ assert_eq!(column(lang), Some(i), "{lang}");
+ }
for (lang, table) in LANGUAGE_TABLES {
let keys: HashSet<_> = table.iter().map(|(key, _)| *key).collect();
assert_eq!(keys.len(), table.len(), "{lang}: duplicate keys");