proto_types/common/
localized_text.rs1use crate::common::LocalizedText;
2
3impl LocalizedText {
4 #[must_use]
6 #[inline]
7 pub fn has_code(&self, code: &str) -> bool {
8 self.language_code == code
9 }
10
11 #[must_use]
14 #[inline]
15 pub fn is_en(&self) -> bool {
16 self.language_code.starts_with("en")
17 }
18
19 #[must_use]
22 #[inline]
23 pub fn is_es(&self) -> bool {
24 self.language_code.starts_with("es")
25 }
26
27 #[must_use]
30 #[inline]
31 pub fn is_fr(&self) -> bool {
32 self.language_code.starts_with("fr")
33 }
34
35 #[must_use]
38 #[inline]
39 pub fn is_de(&self) -> bool {
40 self.language_code.starts_with("de")
41 }
42
43 #[must_use]
46 #[inline]
47 pub fn is_zh_hans(&self) -> bool {
48 self.language_code == "zh-Hans"
49 }
50
51 #[must_use]
54 #[inline]
55 pub fn is_zh_hant(&self) -> bool {
56 self.language_code == "zh-Hant"
57 }
58
59 #[must_use]
62 #[inline]
63 pub fn is_hi(&self) -> bool {
64 self.language_code.starts_with("hi")
65 }
66
67 #[must_use]
70 #[inline]
71 pub fn is_pt(&self) -> bool {
72 self.language_code.starts_with("pt")
73 }
74
75 #[must_use]
78 #[inline]
79 pub fn is_ru(&self) -> bool {
80 self.language_code.starts_with("ru")
81 }
82
83 #[must_use]
86 #[inline]
87 pub fn is_ja(&self) -> bool {
88 self.language_code.starts_with("ja")
89 }
90
91 #[must_use]
94 #[inline]
95 pub fn is_ar(&self) -> bool {
96 self.language_code.starts_with("ar")
97 }
98
99 #[must_use]
102 #[inline]
103 pub fn is_it(&self) -> bool {
104 self.language_code.starts_with("it")
105 }
106}