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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use crate::common::LocalizedText;
impl LocalizedText {
/// Checks if the language code matches the given input.
#[must_use]
#[inline]
pub fn has_code(&self, code: &str) -> bool {
self.language_code == code
}
/// Checks if the language code is for English.
/// This method checks for the primary 'en' subtag.
#[must_use]
#[inline]
pub fn is_en(&self) -> bool {
self.language_code.starts_with("en")
}
/// Checks if the language code is for Spanish.
/// This method checks for the primary 'es' subtag.
#[must_use]
#[inline]
pub fn is_es(&self) -> bool {
self.language_code.starts_with("es")
}
/// Checks if the language code is for French.
/// This method checks for the primary 'fr' subtag.
#[must_use]
#[inline]
pub fn is_fr(&self) -> bool {
self.language_code.starts_with("fr")
}
/// Checks if the language code is for German.
/// This method checks for the primary 'de' subtag.
#[must_use]
#[inline]
pub fn is_de(&self) -> bool {
self.language_code.starts_with("de")
}
/// Checks if the language code is for Simplified Chinese (zh-Hans).
/// This method specifically looks for "zh-Hans".
#[must_use]
#[inline]
pub fn is_zh_hans(&self) -> bool {
self.language_code == "zh-Hans"
}
/// Checks if the language code is for Traditional Chinese (zh-Hant).
/// This method specifically looks for "zh-Hant".
#[must_use]
#[inline]
pub fn is_zh_hant(&self) -> bool {
self.language_code == "zh-Hant"
}
/// Checks if the language code is for Hindi.
/// This method checks for the primary 'hi' subtag.
#[must_use]
#[inline]
pub fn is_hi(&self) -> bool {
self.language_code.starts_with("hi")
}
/// Checks if the language code is for Portuguese.
/// This method checks for the primary 'pt' subtag.
#[must_use]
#[inline]
pub fn is_pt(&self) -> bool {
self.language_code.starts_with("pt")
}
/// Checks if the language code is for Russian.
/// This method checks for the primary 'ru' subtag.
#[must_use]
#[inline]
pub fn is_ru(&self) -> bool {
self.language_code.starts_with("ru")
}
/// Checks if the language code is for Japanese.
/// This method checks for the primary 'ja' subtag.
#[must_use]
#[inline]
pub fn is_ja(&self) -> bool {
self.language_code.starts_with("ja")
}
/// Checks if the language code is for Arabic.
/// This method checks for the primary 'ar' subtag.
#[must_use]
#[inline]
pub fn is_ar(&self) -> bool {
self.language_code.starts_with("ar")
}
/// Checks if the language code is for Italian.
/// This method checks for the primary 'it' subtag.
#[must_use]
#[inline]
pub fn is_it(&self) -> bool {
self.language_code.starts_with("it")
}
}