i18n(ar): add complete Arabic UI translations

This commit is contained in:
zeroxx3d-wq committed 2026-10-15 20:31:02 +01:00
1 parent d2fd1a012a
commit 322b10fbd4
11 files changed
+4402 -10

No files matched your search

+1 -1
View File
@@ -95,7 +95,7 @@ because engine messages are still English. Detail: [localization-parity](docs/lo
| Simplified Chinese | `zh-hans` | 100% | partial |
| Spanish | `es` | 100% | partial |
| Hindi | `hi` | 0% | none |
| Arabic | `ar` | 0% (RTL shell only) | none |
| Arabic | `ar` | 100% | partial |
| French | `fr` | 100% | partial |
| Portuguese (Brazil) | `pt-br` | 100% | partial |
| Indonesian | `id` | 100% | partial |
+3 -2
View File
@@ -17,9 +17,10 @@ fn right_to_left_scripts_by_language_code() {
for code in ["en", "ja", "zh-hans", "pt-br", "ku", "arn", ""] {
assert_eq!(i18n::dir_for_code(code), Dir::Ltr, "{code}");
}
// No right-to-left catalog is registered yet, so the shell stays as it was.
// Arabic is registered as right-to-left; every other catalog is left-to-right.
for lang in Lang::all() {
assert_eq!(lang.dir(), Dir::Ltr, "{}", lang.code());
let expected = if lang.code() == "ar" { Dir::Rtl } else { Dir::Ltr };
assert_eq!(lang.dir(), expected, "{}", lang.code());
}
}
@@ -1,5 +1,5 @@
PhotoCraft's Korean, German, Spanish, Brazilian Portuguese, Italian, Ukrainian, Dutch, Czech,
Turkish, Hungarian and Serbian UI translation catalogs are licensed under MIT OR Apache-2.0,
Turkish, Hungarian, Serbian and Arabic UI translation catalogs are licensed under MIT OR Apache-2.0,
at your option.
The full license texts are in ../../../../LICENSE-MIT and ../../../../LICENSE-APACHE.
@@ -37,3 +37,6 @@ PhotoCraft's English labels; no proprietary translation resources were used.
Serbian translations: PhotoCraft contributors, original translations of
PhotoCraft's English labels; no proprietary translation resources were used.
Arabic translations: PhotoCraft contributors, original translations of
PhotoCraft's English labels; no proprietary translation resources were used.
File diff suppressed because it is too large. Load diff
+2 -2
View File
@@ -219,7 +219,7 @@ fn harness_with_services(services: Services) -> egui_kittest::Harness<'static, P
#[test]
fn first_launch_renders_the_system_language_without_overwriting_auto() {
for (tag, code) in [("en-US", "en"), ("zh-CN", "zh-hans"), ("ja-JP", "ja"), ("ko-KR", "ko"), ("ru-RU", "ru"), ("uk-UA", "uk"), ("fr-CA", "fr")] {
for (tag, code) in [("en-US", "en"), ("zh-CN", "zh-hans"), ("ja-JP", "ja"), ("ko-KR", "ko"), ("ru-RU", "ru"), ("uk-UA", "uk"), ("fr-CA", "fr"), ("ar-SA", "ar")] {
system::with_system_tags(&[tag], || {
with_language(Lang::EN, || {
let h = harness();
@@ -233,7 +233,7 @@ fn first_launch_renders_the_system_language_without_overwriting_auto() {
#[test]
fn missing_or_unsupported_system_languages_render_english() {
for tags in [vec![], vec!["sv-SE", "ar-SA"]] {
for tags in [vec![], vec!["sv-SE", "hi-IN"]] {
system::with_system_tags(&tags, || {
with_language(Lang::EN, || {
let h = harness();
+73 -1
View File
@@ -115,6 +115,23 @@ fn plural_polish(n: u64) -> usize {
}
}
/// Arabic: 6 CLDR forms (zero, one, two, few, many, other).
fn plural_ar(n: u64) -> usize {
if n == 0 {
0
} else if n == 1 {
1
} else if n == 2 {
2
} else {
match n % 100 {
3..=10 => 3,
11..=99 => 4,
_ => 5,
}
}
}
/// A catalog file as packed by build.rs (`pack_catalogs`; the binary would otherwise carry ~2.2 MB
/// of translations, which the web build's size gate can't afford). See [`unpack`].
macro_rules! catalog {
@@ -187,7 +204,7 @@ fn expand(packed: &str, keys: &[&str]) -> Result<String, String> {
}
/// The registry. English first: it is the fallback and the source language.
pub static LANGUAGES: [LangInfo; 21] = [
pub static LANGUAGES: [LangInfo; 22] = [
LangInfo { code: "en", name: "English", source: b"", plural: plural_one_other, complete_menus: false, catalog: OnceLock::new() },
LangInfo { code: "ja", name: "日本語", source: catalog!("ja"), plural: plural_none, complete_menus: true, catalog: OnceLock::new() },
LangInfo { code: "zh-hans", name: "简体中文", source: catalog!("zh-hans"), plural: plural_none, complete_menus: true, catalog: OnceLock::new() },
@@ -220,6 +237,8 @@ pub static LANGUAGES: [LangInfo; 21] = [
LangInfo { code: "tr", name: "Türkçe", source: catalog!("tr"), plural: plural_none, complete_menus: true, catalog: OnceLock::new() },
// Vietnamese; `vi-VN` resolves here.
LangInfo { code: "vi", name: "Tiếng Việt", source: catalog!("vi"), plural: plural_none, complete_menus: true, catalog: OnceLock::new() },
// Arabic; right-to-left layout; 6 CLDR plural forms (zero, one, two, few, many, other).
LangInfo { code: "ar", name: "العربية", source: catalog!("ar"), plural: plural_ar, complete_menus: true, catalog: OnceLock::new() },
];
impl LangInfo {
@@ -832,6 +851,59 @@ mod tests {
}
}
#[test]
fn arabic_resolves_locales_and_preferences() {
let ar = Lang::from_code("ar").expect("ar registered");
assert_eq!(ar.name(), "العربية");
assert!(ar.complete_menus());
assert_eq!(ar.dir(), Dir::Rtl);
for tag in ["ar", "AR", "ar-SA", "ar_SA", "ar_SA.UTF-8", "ar-EG", "ar-AE", "ar-MA"] {
assert_eq!(lang_from_tag(tag), Some(ar), "{tag}");
assert_eq!(Lang::from_pref(tag), ar, "{tag}");
}
assert_eq!(tr(ar, "File"), "ملف");
assert_eq!(tr(ar, "Layer"), "طبقة");
assert_eq!(tr(ar, "New document…"), "مستند جديد…");
assert_eq!(tr_id(ar, "select.all", "All"), "تحديد الكل", "an id override wins over the plain label");
assert_eq!(tr_ctx(ar, "cameraRaw", "Light"), "إضاءة");
assert_eq!(tr_ctx(ar, "fontWeight", "Light"), "خفيف");
assert_eq!(tr_ctx(ar, "cameraRaw", "Highlights"), "إبرازات");
assert_eq!(tr_ctx(ar, "cameraRaw", "Lights"), "مناطق مضيئة");
assert_eq!(tr_ctx(ar, "cameraRaw", "Shadows"), "ظلال");
assert_eq!(tr_ctx(ar, "cameraRaw", "Darks"), "مناطق داكنة");
assert_eq!(fmt(tr(ar, "Camera Raw Filter ({layer})"), &[("layer", "Background")]), "مرشح Camera Raw (Background)");
for key in ["Alt", "⌥"] {
assert_eq!(
fmt(tr(ar, "Add a mask (from the selection; {key} inverts)"), &[("key", key)]),
format!("إضافة قناع (من التحديد؛ {key} يعكس)")
);
}
}
#[test]
fn arabic_plural_messages_handle_six_forms() {
let ar = Lang::from_code("ar").expect("ar registered");
for (n, item, layer) in [
(0, "عنصر", "طبقة"),
(1, "عنصر", "طبقة"),
(2, "عنصران", "طبقتان"),
(3, "عناصر", "طبقات"),
(5, "عناصر", "طبقات"),
(10, "عناصر", "طبقات"),
(11, "عنصرًا", "طبقة"),
(25, "عنصرًا", "طبقة"),
(99, "عنصرًا", "طبقة"),
(100, "عنصر", "طبقة"),
(101, "عنصر", "طبقة"),
(102, "عنصر", "طبقة"),
(103, "عناصر", "طبقات"),
(115, "عنصرًا", "طبقة"),
] {
assert_eq!(trn(ar, n, "{n} item", "{n} items"), format!("{n} {item}"));
assert_eq!(trn(ar, n, "{n} layer", "{n} layers"), format!("{n} {layer}"));
}
}
#[test]
fn catalog_kinds_are_parsed_and_looked_up() {
let c = Catalog::parse("# c\n\tHello\tこんにちは\n@id\tfile.save\t保存する\nmenu\tWindows\tウィンドウ群\n@plural\t{n} file|{n} files\t{n} 個\n\n");
+3 -1
View File
@@ -91,7 +91,9 @@ mod tests {
(vec!["zh-Hant-HK", "zh-CN"], "zh-hant"),
(vec!["zh-Hans-CN", "zh-TW"], "zh-hans"),
(vec!["en-US", "ru-RU"], "en"),
(vec!["sv-SE", "ar-SA"], "en"),
(vec!["sv-SE", "hi-IN"], "en"),
(vec!["ar-SA", "en-US"], "ar"),
(vec!["sv-SE", "ar-EG"], "ar"),
(vec!["de-AT", "en-US"], "de"),
(vec!["pt-PT"], "pt-br"),
(vec!["it-IT", "en-US"], "it"),
+1 -1
View File
@@ -34,7 +34,7 @@ speakers, ~55% ready. Remaining: 80–140 h, plus native-speaker review (recorde
| Simplified Chinese | `zh-hans` | 1,608 / 1,608 (100%) | 2,366 | dialogs, tooltips yes; engine messages English | CJK fonts (lazy loader), IME preedit/commit, vertical type | no | partial | 8–12 h |
| Spanish | `es` | 1,844 / 1,844 (100%) | 4,010 | as above; complete dynamic UI key set | Latin | no | partial | 6–10 h |
| Hindi | `hi` | 0 (0%) | – | – | Devanagari shaping in the text engine (parley/HarfRust); no Devanagari fallback font (TYPE-218-3) | no | none | 20–30 h |
| Arabic | `ar` | 0 (0%) | – | – | Arabic shaping and bidi in the text engine, Arabic fallback font; RTL shell layout but not inside panels, and UI labels in LTR word order (DIST-220-4), paragraph direction has no UI (TYPE-218-2), layer names as tofu (#1408, #1693) | no | none | 40–60 h |
| Arabic | `ar` | 1,886 / 1,886 (100%) | 4,208 | dialogs, tooltips yes; engine messages English | Arabic shaping and bidi in the text engine, Arabic fallback font; RTL layout | no | partial | 8–12 h |
| French | `fr` | 1,608 / 1,608 (100%) | 2,766 | as above | Latin | no | partial | 6–10 h |
| Portuguese (Brazil) | `pt-br` | 1,608 / 1,608 (100%) | 2,788 | as above | Latin; every `pt` locale uses it | no | partial | 6–10 h |
| Indonesian | `id` | 1,608 / 1,608 (100%) | 2,764 | as above | Latin | no | partial | 6–10 h |
+1 -1
View File
@@ -106,7 +106,7 @@ glyphs) and bidirectional word order: egui 0.36 shapes each right-to-left word w
so letters join, but lays a line's words out left to right, and its caret indexing is off in
right-to-left text (emilk/egui#8576, #8577). Document text is laid out by the text engine.
No right-to-left catalog ships yet. To check the mirrored layout with any language, launch with
Arabic (`ar`) is the first shipped right-to-left catalog. To check the mirrored layout with any language, launch with
`PHOTOCRAFT_UI_DIRECTION=rtl` (or `ltr` to force left-to-right); it is read once per process
and has no effect on the web build:
+1
View File
@@ -31,6 +31,7 @@
<string>hu</string>
<string>tr</string>
<string>vi</string>
<string>ar</string>
</array>
<key>CFBundleDisplayName</key>
<string>PhotoCraft</string>
+1
View File
@@ -583,6 +583,7 @@ mod tests {
("tr", "tr.tsv"),
("vi", "vi.tsv"),
("sr", "sr.tsv"),
("ar", "ar.tsv"),
] {
let catalog_path = root.join("crates/ui-egui/src/i18n").join(path);
let text = fs::read_to_string(&catalog_path).unwrap_or_default();