# Conflicts:
#	docs/translating.md
This commit is contained in:
bflatastic
2026-10-20 02:05:46 +07:00
4 changed files with 2372 additions and 5 deletions
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -171,9 +171,10 @@ fn plural(code: &str, n: usize) -> Plural {
"cs" if n == 1 => Plural::One,
"cs" if (2..=4).contains(&n) => Plural::Few,
"cs" => Plural::Other,
"pl" if n == 1 => Plural::One,
"ru" if n % 10 == 1 && n % 100 != 11 => Plural::One,
"ru" if (2..=4).contains(&(n % 10)) && !(12..=14).contains(&(n % 100)) => Plural::Few,
"ru" => Plural::Many,
"ru" | "pl" if (2..=4).contains(&(n % 10)) && !(12..=14).contains(&(n % 100)) => Plural::Few,
"ru" | "pl" => Plural::Many,
"ja" | "ko" | "zh-Hans" => Plural::Other,
"fr" | "pt-BR" if n <= 1 => Plural::One,
_ if n == 1 => Plural::One,
@@ -182,7 +183,7 @@ fn plural(code: &str, n: usize) -> Plural {
}
// CLDR's million-count "many" in French, Spanish and Portuguese still reads their existing
// "other" wording. Czech supplies separate few forms; Russian supplies few/many forms.
// "other" wording. Czech supplies separate few forms; Russian and Polish supply few/many forms.
/// Whether count `n` takes the "one" form: 0 and 1 in French and Brazilian Portuguese, never in
/// Japanese, Korean and Chinese (no plural forms: always "other"), 1 elsewhere (CLDR's integer rules).
+22 -1
View File
@@ -400,7 +400,7 @@ fn french_and_portuguese_count_zero_as_singular() {
for code in ["fr", "pt-BR"] {
assert!(one(code, 0) && one(code, 1) && !one(code, 2), "{code}");
}
for code in ["en", "es", "de", "cs"] {
for code in ["en", "es", "de", "cs", "pl"] {
for n in [0, 1, 2, 3, 4, 5, 21] {
assert_eq!(one(code, n), n == 1, "{code}: {n}");
}
@@ -528,6 +528,27 @@ fn russian_language_tags_and_integer_plurals() {
}
}
#[test]
fn polish_integer_plurals() {
let pl = LANGS.iter().position(|l| l.code == "pl").unwrap();
assert_eq!(LANGS[pl].name, "Polski");
assert_eq!(plural("pl", 1), Plural::One);
assert_eq!(fill(counted(pl, "{n} layers", 1), &[("n", &1)]), "1 warstwa");
for n in [2, 3, 4, 22, 23, 24, 102, 104, 1_002] {
assert_eq!(plural("pl", n), Plural::Few, "{n}");
assert_eq!(fill(counted(pl, "{n} layers", n), &[("n", &n)]), format!("{n} warstwy"));
}
for n in [0, 5, 10, 11, 12, 13, 14, 19, 20, 21, 25, 31, 100, 101, 111, 112, 114, 1_000_000] {
assert_eq!(plural("pl", n), Plural::Many, "{n}");
assert_eq!(fill(counted(pl, "{n} layers", n), &[("n", &n)]), format!("{n} warstw"));
}
for (key, text) in LANGS[pl].ui {
if let Text::Plural { one, few, many, .. } = text {
assert!(one.is_some() && few.is_some() && many.is_some(), "{key}: missing Polish plural forms");
}
}
}
#[test]
fn plural_fallback_uses_the_language_of_its_catalog() {
let la = LANGS.iter().position(|l| l.code == "es-419").unwrap();
+3 -1
View File
@@ -17,7 +17,7 @@ Simplified.
The catalogs: English (`en`, the source), and Spanish (`es`, with the Latin American overlay
`es-419`), French (`fr`), German (`de`), Dutch (`nl`), Brazilian Portuguese (`pt-BR`), Japanese
(`ja`), Korean (`ko`), Simplified Chinese (`zh-Hans`), Czech (`cs`), Indonesian (`id`), Finnish
(`fi`) and Georgian (`ka`), machine-drafted and waiting for native speakers' review. Russian (`ru`, Русский) was
(`fi`), Polish (`pl`) and Georgian (`ka`), machine-drafted and waiting for native speakers' review. Russian (`ru`, Русский) was
reviewed and approved by VanTan; its catalog keeps Frame, Dev Mode and Smart animate as familiar
tool names and uses « » quotes. Turkish (`tr`) was machine-drafted and reviewed by a native speaker,
and Swedish (`sv`) translates every UI string, command label and menu wording.
@@ -86,6 +86,8 @@ picker leaves Georgian out. A new CJK or other non-Latin language also needs its
a missing key uses the fallback catalog's own plural rule. Czech uses `one` for 1, `few` for
2–4 and `other` for 0 and 5+ (e.g. `{n} vrstva`, `{n} vrstvy`, `{n} vrstev`). Keep `{n}` in all
three forms. Czech's CLDR `many` applies only to decimals; `trn` takes integer counts.
Polish uses `one` for 1 only, `few` like Russian (2–4, 22–24… except 12–14) and `many` for
the other integers, including 0 and 21 (e.g. `{n} warstwa`, `{n} warstwy`, `{n} warstw`).
4. To require full coverage, add the code to `COMPLETE` in
[`crates/ui-egui/src/i18n_tests.rs`](../crates/ui-egui/src/i18n_tests.rs). Every later PR that
adds a string then has to translate it into each complete language, so only Spanish is there: