Add Arabic (ar) as the first right-to-left UI language

- Register ar in LANGUAGES with plural_arabic (CLDR 6 forms: zero, one, two, few, many, other)
- Add crates/ui-egui/src/i18n/ar.tsv with full menu and UI coverage
- Update direction_tests for the first RTL catalog
- Update live_tests.rs and system.rs: ar is now a registered language, so the
  "unsupported language" fixtures use xx-XX instead
- Fill missing keys in hu.tsv (Enable animations) and tr.tsv (8/16 Bit, Enable animations)

Arabic script fallback fonts are already handled on demand by cjk_fonts.rs
(see #1693), so no bundled font is required.
This commit is contained in:
hicbest committed 2026-10-12 23:33:59 +01:00
1 parent d43db3e153
commit 74cd4faec9
7 files changed
+3023 -8

No files matched your search

+6 -3
View File
@@ -17,12 +17,15 @@ 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.
// Registered languages follow their script: Arabic is right-to-left, the rest left-to-right.
for lang in Lang::all() {
assert_eq!(lang.dir(), Dir::Ltr, "{}", lang.code());
let expected = match lang.code() {
"ar" => Dir::Rtl,
_ => Dir::Ltr,
};
assert_eq!(lang.dir(), expected, "{}", lang.code());
}
}
#[test]
fn direction_follows_the_language_unless_forced() {
let _lang = i18n::language_scope(Lang::EN);
File diff suppressed because it is too large. Load diff
+1
View File
@@ -3970,3 +3970,4 @@ cameraRaw Yellow Sárga
Transform On Drop Átalakítás elengedéskor
Vanishing Point is not active Az Enyészpont nem aktív
Vanishing Point: click four corners to create a plane Enyészpont: sík létrehozásához kattintson a négy sarokra
Enable animations Animációk engedélyezése
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1 -1
View File
@@ -231,7 +231,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", "xx-XX"]] {
system::with_system_tags(&tags, || {
with_language(Lang::EN, || {
let h = harness();
+13 -1
View File
@@ -115,6 +115,17 @@ fn plural_polish(n: u64) -> usize {
}
}
/// Arabic (CLDR): 0 → zero, 1 → one, 2 → two, 3–10 → few, 11–99 → many, 100+ → other.
fn plural_arabic(n: u64) -> usize {
match n {
0 => 0,
1 => 1,
2 => 2,
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,8 +198,9 @@ 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; 20] = [
pub static LANGUAGES: [LangInfo; 21] = [
LangInfo { code: "en", name: "English", source: b"", plural: plural_one_other, complete_menus: false, catalog: OnceLock::new() },
LangInfo { code: "ar", name: "العربية", source: catalog!("ar"), plural: plural_arabic, complete_menus: true, 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() },
// Traditional Chinese in the vocabulary used in Taiwan; `zh-TW`, `zh-HK`, `zh-MO` and `zh-Hant-*`
+1 -1
View File
@@ -91,7 +91,7 @@ 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", "xx-XX"], "en"),
(vec!["de-AT", "en-US"], "de"),
(vec!["pt-PT"], "pt-br"),
(vec!["it-IT", "en-US"], "it"),
+5 -2
View File
@@ -202,10 +202,10 @@
Lab Color Laboratuvar Rengi
Multichannel Çok kanallı
8 Bits/Channel 8 Bit/Kanal
8 bit 8 bit
8 bit 8 Bit
Integer Tamsayı
16 Bits/Channel 16 Bit/Kanal
16 bit 16 bit
16 bit 16 Bit
32 Bits/Channel 32 Bit/Kanal
32 bit (float) 32 bit (kayan)
Floating point Kayan nokta
@@ -3782,3 +3782,6 @@ cameraData Lens Lens
@plural {n} step|{n} steps {n} adım
@plural {warning} (+{n} more brush preset warning)|{warning} (+{n} more brush preset warnings) {warning} (+{n} fırça ön ayarı uyarısı daha)
@plural {what} with {n} warning|{what} with {n} warnings {what}, {n} uyarı ile
Enable animations Animasyonları etkinleştir
Can't render this file because it contains an unexpected character in line 8 and column 34.