1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#![feature(decl_macro)]
pub mod locale;
pub use locale::Locale;
pub use fluent;
pub mod ftl;
#[derive(Copy, Clone, PartialEq)]
pub enum TextDirection {
Ltr,
Rtl,
}
pub trait HasTextDirection {
fn text_direction(&self) -> TextDirection;
}
impl HasTextDirection for locale::Locale {
fn text_direction(&self) -> TextDirection {
self.id.text_direction()
}
}
impl HasTextDirection for locale::LanguageIdentifier {
fn text_direction(&self) -> TextDirection {
match self.language.as_str() {
| "ar" | "ara"
| "arc"
| "az" | "aze"
| "dv" | "div"
| "he" | "heb"
| "ku" | "kur"
| "fa" | "per" | "fas"
| "ur" | "urd"
=> TextDirection::Rtl,
_ => TextDirection::Ltr,
}
}
}