-
Notifications
You must be signed in to change notification settings - Fork 66
/
isocode.go
523 lines (363 loc) · 9.16 KB
/
isocode.go
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
/*
* Copyright © 2021-present Peter M. Stahl [email protected]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expressed or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lingua
import "strings"
// IsoCode639_1 is the type used for enumerating the ISO 639-1 code
// representations of the supported languages.
//
//go:generate stringer -type=IsoCode639_1
type IsoCode639_1 int
// IsoCode639_3 is the type used for enumerating the ISO 639-3 code
// representations of the supported languages.
//
//go:generate stringer -type=IsoCode639_3
type IsoCode639_3 int
const (
// AF is the ISO 639-1 code for Afrikaans.
AF IsoCode639_1 = iota
// AR is the ISO 639-1 code for Arabic.
AR
// AZ is the ISO 639-1 code for Azerbaijani.
AZ
// BE is the ISO 639-1 code for Belarusian.
BE
// BG is the ISO 639-1 code for Bulgarian.
BG
// BN is the ISO 639-1 code for Bengali.
BN
// BS is the ISO 639-1 code for Bosnian.
BS
// CA is the ISO 639-1 code for Catalan.
CA
// CS is the ISO 639-1 code for Czech.
CS
// CY is the ISO 639-1 code for Welsh.
CY
// DA is the ISO 639-1 code for Danish.
DA
// DE is the ISO 639-1 code for German.
DE
// EL is the ISO 639-1 code for Greek.
EL
// EN is the ISO 639-1 code for English.
EN
// EO is the ISO 639-1 code for Esperanto.
EO
// ES is the ISO 639-1 code for Spanish.
ES
// ET is the ISO 639-1 code for Estonian.
ET
// EU is the ISO 639-1 code for Basque.
EU
// FA is the ISO 639-1 code for Persian.
FA
// FI is the ISO 639-1 code for Finnish.
FI
// FR is the ISO 639-1 code for French.
FR
// GA is the ISO 639-1 code for Irish.
GA
// GU is the ISO 639-1 code for Gujarati.
GU
// HE is the ISO 639-1 code for Hebrew.
HE
// HI is the ISO 639-1 code for Hindi.
HI
// HR is the ISO 639-1 code for Croatian.
HR
// HU is the ISO 639-1 code for Hungarian.
HU
// HY is the ISO 639-1 code for Armenian.
HY
// ID is the ISO 639-1 code for Indonesian.
ID
// IS is the ISO 639-1 code for Icelandic.
IS
// IT is the ISO 639-1 code for Italian.
IT
// JA is the ISO 639-1 code for Japanese.
JA
// KA is the ISO 639-1 code for Georgian.
KA
// KK is the ISO 639-1 code for Kazakh.
KK
// KO is the ISO 639-1 code for Korean.
KO
// LA is the ISO 639-1 code for Latin.
LA
// LG is the ISO 639-1 code for Ganda.
LG
// LT is the ISO 639-1 code for Lithuanian.
LT
// LV is the ISO 639-1 code for Latvian.
LV
// MI is the ISO 639-1 code for Maori.
MI
// MK is the ISO 639-1 code for Macedonian.
MK
// MN is the ISO 639-1 code for Mongolian.
MN
// MR is the ISO 639-1 code for Marathi.
MR
// MS is the ISO 639-1 code for Malay.
MS
// NB is the ISO 639-1 code for Bokmal.
NB
// NL is the ISO 639-1 code for Dutch.
NL
// NN is the ISO 639-1 code for Nynorsk.
NN
// PA is the ISO 639-1 code for Punjabi.
PA
// PL is the ISO 639-1 code for Polish.
PL
// PT is the ISO 639-1 code for Portuguese.
PT
// RO is the ISO 639-1 code for Romanian.
RO
// RU is the ISO 639-1 code for Russian.
RU
// SK is the ISO 639-1 code for Slovak.
SK
// SL is the ISO 639-1 code for Slovene.
SL
// SN is the ISO 639-1 code for Shona.
SN
// SO is the ISO 639-1 code for Somali.
SO
// SQ is the ISO 639-1 code for Albanian.
SQ
// SR is the ISO 639-1 code for Serbian.
SR
// ST is the ISO 639-1 code for Sotho.
ST
// SV is the ISO 639-1 code for Swedish.
SV
// SW is the ISO 639-1 code for Swahili.
SW
// TA is the ISO 639-1 code for Tamil.
TA
// TE is the ISO 639-1 code for Telugu.
TE
// TH is the ISO 639-1 code for Thai.
TH
// TL is the ISO 639-1 code for Tagalog.
TL
// TN is the ISO 639-1 code for Tswana.
TN
// TR is the ISO 639-1 code for Turkish.
TR
// TS is the ISO 639-1 code for Tsonga.
TS
// UK is the ISO 639-1 code for Ukrainian.
UK
// UR is the ISO 639-1 code for Urdu.
UR
// VI is the ISO 639-1 code for Vietnamese.
VI
// XH is the ISO 639-1 code for Xhosa.
XH
// YO is the ISO 639-1 code for Yoruba.
YO
// ZH is the ISO 639-1 code for Chinese.
ZH
// ZU is the ISO 639-1 code for Zulu.
ZU
// UnknownIsoCode639_1 is the ISO 639-1 code for Unknown.
UnknownIsoCode639_1
)
const (
// AFR is the ISO 639-3 code for Afrikaans.
AFR IsoCode639_3 = iota
// ARA is the ISO 639-3 code for Arabic.
ARA
// AZE is the ISO 639-3 code for Azerbaijani.
AZE
// BEL is the ISO 639-3 code for Belarusian.
BEL
// BEN is the ISO 639-3 code for Bengali.
BEN
// BOS is the ISO 639-3 code for Bosnian.
BOS
// BUL is the ISO 639-3 code for Bulgarian.
BUL
// CAT is the ISO 639-3 code for Catalan.
CAT
// CES is the ISO 639-3 code for Czech.
CES
// CYM is the ISO 639-3 code for Welsh.
CYM
// DAN is the ISO 639-3 code for Danish.
DAN
// DEU is the ISO 639-3 code for German.
DEU
// ELL is the ISO 639-3 code for Greek.
ELL
// ENG is the ISO 639-3 code for English.
ENG
// EPO is the ISO 639-3 code for Esperanto.
EPO
// EST is the ISO 639-3 code for Estonian.
EST
// EUS is the ISO 639-3 code for Basque.
EUS
// FAS is the ISO 639-3 code for Persian.
FAS
// FIN is the ISO 639-3 code for Finnish.
FIN
// FRA is the ISO 639-3 code for French.
FRA
// GLE is the ISO 639-3 code for Irish.
GLE
// GUJ is the ISO 639-3 code for Gujarati.
GUJ
// HEB is the ISO 639-3 code for Hebrew.
HEB
// HIN is the ISO 639-3 code for Hindi.
HIN
// HRV is the ISO 639-3 code for Croatian.
HRV
// HUN is the ISO 639-3 code for Hungarian.
HUN
// HYE is the ISO 639-3 code for Armenian.
HYE
// IND is the ISO 639-3 code for Indonesian.
IND
// ISL is the ISO 639-3 code for Icelandic.
ISL
// ITA is the ISO 639-3 code for Italian.
ITA
// JPN is the ISO 639-3 code for Japanese.
JPN
// KAT is the ISO 639-3 code for Georgian.
KAT
// KAZ is the ISO 639-3 code for Kazakh.
KAZ
// KOR is the ISO 639-3 code for Korean.
KOR
// LAT is the ISO 639-3 code for Latin.
LAT
// LAV is the ISO 639-3 code for Latvian.
LAV
// LIT is the ISO 639-3 code for Lithuanian.
LIT
// LUG is the ISO 639-3 code for Ganda.
LUG
// MAR is the ISO 639-3 code for Marathi.
MAR
// MKD is the ISO 639-3 code for Macedonian.
MKD
// MON is the ISO 639-3 code for Mongolian.
MON
// MRI is the ISO 639-3 code for Maori.
MRI
// MSA is the ISO 639-3 code for Malay.
MSA
// NLD is the ISO 639-3 code for Dutch.
NLD
// NNO is the ISO 639-3 code for Nynorsk.
NNO
// NOB is the ISO 639-3 code for Bokmal.
NOB
// PAN is the ISO 639-3 code for Punjabi.
PAN
// POL is the ISO 639-3 code for Polish.
POL
// POR is the ISO 639-3 code for Portuguese.
POR
// RON is the ISO 639-3 code for Romanian.
RON
// RUS is the ISO 639-3 code for Russian.
RUS
// SLK is the ISO 639-3 code for Slovak.
SLK
// SLV is the ISO 639-3 code for Slovene.
SLV
// SNA is the ISO 639-3 code for Shona.
SNA
// SOM is the ISO 639-3 code for Somali.
SOM
// SOT is the ISO 639-3 code for Sotho.
SOT
// SPA is the ISO 639-3 code for Spanish.
SPA
// SQI is the ISO 639-3 code for Albanian.
SQI
// SRP is the ISO 639-3 code for Serbian.
SRP
// SWA is the ISO 639-3 code for Swahili.
SWA
// SWE is the ISO 639-3 code for Swedish.
SWE
// TAM is the ISO 639-3 code for Tamil.
TAM
// TEL is the ISO 639-3 code for Telugu.
TEL
// TGL is the ISO 639-3 code for Tagalog.
TGL
// THA is the ISO 639-3 code for Thai.
THA
// TSN is the ISO 639-3 code for Tswana.
TSN
// TSO is the ISO 639-3 code for Tsonga.
TSO
// TUR is the ISO 639-3 code for Turkish.
TUR
// UKR is the ISO 639-3 code for Ukrainian.
UKR
// URD is the ISO 639-3 code for Urdu.
URD
// VIE is the ISO 639-3 code for Vietnamese.
VIE
// XHO is the ISO 639-3 code for Xhosa.
XHO
// YOR is the ISO 639-3 code for Yoruba.
YOR
// ZHO is the ISO 639-3 code for Chinese.
ZHO
// ZUL is the ISO 639-3 code for Zulu.
ZUL
// UnknownIsoCode639_3 is the ISO 639-3 code for Unknown.
UnknownIsoCode639_3
)
// GetIsoCode639_1FromValue returns the ISO 639-1 code for the given name.
func GetIsoCode639_1FromValue(name string) IsoCode639_1 {
if isoCodeEnum, ok := stringToIsoCode639_1[strings.ToLower(name)]; ok {
return isoCodeEnum
}
return UnknownIsoCode639_1
}
// GetIsoCode639_3FromValue returns the ISO 639-3 code for the given name.
func GetIsoCode639_3FromValue(name string) IsoCode639_3 {
if isoCodeEnum, ok := stringToIsoCode639_3[strings.ToLower(name)]; ok {
return isoCodeEnum
}
return UnknownIsoCode639_3
}
var stringToIsoCode639_1 = func() map[string]IsoCode639_1 {
m := make(map[string]IsoCode639_1)
for isoCode := AF; isoCode <= ZU; isoCode++ {
m[strings.ToLower(isoCode.String())] = isoCode
}
return m
}()
var stringToIsoCode639_3 = func() map[string]IsoCode639_3 {
m := make(map[string]IsoCode639_3)
for isoCode := AFR; isoCode <= ZUL; isoCode++ {
m[strings.ToLower(isoCode.String())] = isoCode
}
return m
}()