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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
use crate::errors::Result;
use crate::types::*;
use uuid::Uuid;

/// Contains information about a language pack
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct LanguagePackInfo {
    #[doc(hidden)]
    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
    extra: Option<String>,
    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
    client_id: Option<i32>,
    /// Unique language pack identifier

    #[serde(default)]
    id: String,
    /// Identifier of a base language pack; may be empty. If a string is missed in the language pack, then it must be fetched from base language pack. Unsupported in custom language packs

    #[serde(default)]
    base_language_pack_id: String,
    /// Language name

    #[serde(default)]
    name: String,
    /// Name of the language in that language

    #[serde(default)]
    native_name: String,
    /// A language code to be used to apply plural forms. See https://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html for more info

    #[serde(default)]
    plural_code: String,
    /// True, if the language pack is official

    #[serde(default)]
    is_official: bool,
    /// True, if the language pack strings are RTL

    #[serde(default)]
    is_rtl: bool,
    /// True, if the language pack is a beta language pack

    #[serde(default)]
    is_beta: bool,
    /// True, if the language pack is installed by the current user

    #[serde(default)]
    is_installed: bool,
    /// Total number of non-deleted strings from the language pack

    #[serde(default)]
    total_string_count: i32,
    /// Total number of translated strings from the language pack

    #[serde(default)]
    translated_string_count: i32,
    /// Total number of non-deleted strings from the language pack available locally

    #[serde(default)]
    local_string_count: i32,
    /// Link to language translation interface; empty for custom local language packs

    #[serde(default)]
    translation_url: String,
}

impl RObject for LanguagePackInfo {
    #[doc(hidden)]
    fn extra(&self) -> Option<&str> {
        self.extra.as_deref()
    }
    #[doc(hidden)]
    fn client_id(&self) -> Option<i32> {
        self.client_id
    }
}

impl LanguagePackInfo {
    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
        Ok(serde_json::from_str(json.as_ref())?)
    }
    pub fn builder() -> LanguagePackInfoBuilder {
        let mut inner = LanguagePackInfo::default();
        inner.extra = Some(Uuid::new_v4().to_string());

        LanguagePackInfoBuilder { inner }
    }

    pub fn id(&self) -> &String {
        &self.id
    }

    pub fn base_language_pack_id(&self) -> &String {
        &self.base_language_pack_id
    }

    pub fn name(&self) -> &String {
        &self.name
    }

    pub fn native_name(&self) -> &String {
        &self.native_name
    }

    pub fn plural_code(&self) -> &String {
        &self.plural_code
    }

    pub fn is_official(&self) -> bool {
        self.is_official
    }

    pub fn is_rtl(&self) -> bool {
        self.is_rtl
    }

    pub fn is_beta(&self) -> bool {
        self.is_beta
    }

    pub fn is_installed(&self) -> bool {
        self.is_installed
    }

    pub fn total_string_count(&self) -> i32 {
        self.total_string_count
    }

    pub fn translated_string_count(&self) -> i32 {
        self.translated_string_count
    }

    pub fn local_string_count(&self) -> i32 {
        self.local_string_count
    }

    pub fn translation_url(&self) -> &String {
        &self.translation_url
    }
}

#[doc(hidden)]
pub struct LanguagePackInfoBuilder {
    inner: LanguagePackInfo,
}

#[deprecated]
pub type RTDLanguagePackInfoBuilder = LanguagePackInfoBuilder;

impl LanguagePackInfoBuilder {
    pub fn build(&self) -> LanguagePackInfo {
        self.inner.clone()
    }

    pub fn id<T: AsRef<str>>(&mut self, id: T) -> &mut Self {
        self.inner.id = id.as_ref().to_string();
        self
    }

    pub fn base_language_pack_id<T: AsRef<str>>(&mut self, base_language_pack_id: T) -> &mut Self {
        self.inner.base_language_pack_id = base_language_pack_id.as_ref().to_string();
        self
    }

    pub fn name<T: AsRef<str>>(&mut self, name: T) -> &mut Self {
        self.inner.name = name.as_ref().to_string();
        self
    }

    pub fn native_name<T: AsRef<str>>(&mut self, native_name: T) -> &mut Self {
        self.inner.native_name = native_name.as_ref().to_string();
        self
    }

    pub fn plural_code<T: AsRef<str>>(&mut self, plural_code: T) -> &mut Self {
        self.inner.plural_code = plural_code.as_ref().to_string();
        self
    }

    pub fn is_official(&mut self, is_official: bool) -> &mut Self {
        self.inner.is_official = is_official;
        self
    }

    pub fn is_rtl(&mut self, is_rtl: bool) -> &mut Self {
        self.inner.is_rtl = is_rtl;
        self
    }

    pub fn is_beta(&mut self, is_beta: bool) -> &mut Self {
        self.inner.is_beta = is_beta;
        self
    }

    pub fn is_installed(&mut self, is_installed: bool) -> &mut Self {
        self.inner.is_installed = is_installed;
        self
    }

    pub fn total_string_count(&mut self, total_string_count: i32) -> &mut Self {
        self.inner.total_string_count = total_string_count;
        self
    }

    pub fn translated_string_count(&mut self, translated_string_count: i32) -> &mut Self {
        self.inner.translated_string_count = translated_string_count;
        self
    }

    pub fn local_string_count(&mut self, local_string_count: i32) -> &mut Self {
        self.inner.local_string_count = local_string_count;
        self
    }

    pub fn translation_url<T: AsRef<str>>(&mut self, translation_url: T) -> &mut Self {
        self.inner.translation_url = translation_url.as_ref().to_string();
        self
    }
}

impl AsRef<LanguagePackInfo> for LanguagePackInfo {
    fn as_ref(&self) -> &LanguagePackInfo {
        self
    }
}

impl AsRef<LanguagePackInfo> for LanguagePackInfoBuilder {
    fn as_ref(&self) -> &LanguagePackInfo {
        &self.inner
    }
}