Repository navigation
Expand file tree
/
Copy pathLocaleISOData.java
More file actions
582 lines (565 loc) · 23.3 KB
/
Copy pathLocaleISOData.java
File metadata and controls
582 lines (565 loc) · 23.3 KB
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
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
/*
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package java.util;
import java.util.function.Supplier;
// Methods and suppliers for producing ISO 639/3166 resources used by Locale.
class LocaleISOData {
static final LazyConstant<String[]> ISO_639 =
LazyConstant.of(new Supplier<>() {
@Override
public String[] get() {
return getISO2Table(isoLanguageTable);
}
});
static final LazyConstant<String[]> ISO_3166_1_ALPHA2 =
LazyConstant.of(new Supplier<>() {
@Override
public String[] get() {
return getISO2Table(isoCountryTable);
}
});
static final LazyConstant<Set<String>> ISO_3166_1_ALPHA3 =
LazyConstant.of(new Supplier<>() {
@Override
public Set<String> get() {
return computeISO3166_1Alpha3Countries();
}
});
static final LazyConstant<Set<String>> ISO_3166_3 =
LazyConstant.of(new Supplier<>() {
@Override
public Set<String> get() {
return Set.of(ISO3166_3);
}
});
/**
* The 2- and 3-letter ISO 639 language codes.
*/
private static final String isoLanguageTable =
"aa" + "aar" // Afar
+ "ab" + "abk" // Abkhazian
+ "ae" + "ave" // Avestan
+ "af" + "afr" // Afrikaans
+ "ak" + "aka" // Akan
+ "am" + "amh" // Amharic
+ "an" + "arg" // Aragonese
+ "ar" + "ara" // Arabic
+ "as" + "asm" // Assamese
+ "av" + "ava" // Avaric
+ "ay" + "aym" // Aymara
+ "az" + "aze" // Azerbaijani
+ "ba" + "bak" // Bashkir
+ "be" + "bel" // Belarusian
+ "bg" + "bul" // Bulgarian
+ "bh" + "bih" // Bihari languages
+ "bi" + "bis" // Bislama
+ "bm" + "bam" // Bambara
+ "bn" + "ben" // Bengali
+ "bo" + "bod" // Tibetan
+ "br" + "bre" // Breton
+ "bs" + "bos" // Bosnian
+ "ca" + "cat" // Catalan
+ "ce" + "che" // Chechen
+ "ch" + "cha" // Chamorro
+ "co" + "cos" // Corsican
+ "cr" + "cre" // Cree
+ "cs" + "ces" // Czech
+ "cu" + "chu" // Church Slavic
+ "cv" + "chv" // Chuvash
+ "cy" + "cym" // Welsh
+ "da" + "dan" // Danish
+ "de" + "deu" // German
+ "dv" + "div" // Divehi
+ "dz" + "dzo" // Dzongkha
+ "ee" + "ewe" // Ewe
+ "el" + "ell" // Greek
+ "en" + "eng" // English
+ "eo" + "epo" // Esperanto
+ "es" + "spa" // Spanish
+ "et" + "est" // Estonian
+ "eu" + "eus" // Basque
+ "fa" + "fas" // Persian
+ "ff" + "ful" // Fulah
+ "fi" + "fin" // Finnish
+ "fj" + "fij" // Fijian
+ "fo" + "fao" // Faroese
+ "fr" + "fra" // French
+ "fy" + "fry" // Western Frisian
+ "ga" + "gle" // Irish
+ "gd" + "gla" // Scottish Gaelic
+ "gl" + "glg" // Galician
+ "gn" + "grn" // Guarani
+ "gu" + "guj" // Gujarati
+ "gv" + "glv" // Manx
+ "ha" + "hau" // Hausa
+ "he" + "heb" // Hebrew
+ "hi" + "hin" // Hindi
+ "ho" + "hmo" // Hiri Motu
+ "hr" + "hrv" // Croatian
+ "ht" + "hat" // Haitian
+ "hu" + "hun" // Hungarian
+ "hy" + "hye" // Armenian
+ "hz" + "her" // Herero
+ "ia" + "ina" // Interlingua
+ "id" + "ind" // Indonesian
+ "ie" + "ile" // Interlingue
+ "ig" + "ibo" // Igbo
+ "ii" + "iii" // Sichuan Yi
+ "ik" + "ipk" // Inupiaq
+ "in" + "ind" // Indonesian (old)
+ "io" + "ido" // Ido
+ "is" + "isl" // Icelandic
+ "it" + "ita" // Italian
+ "iu" + "iku" // Inuktitut
+ "iw" + "heb" // Hebrew (old)
+ "ja" + "jpn" // Japanese
+ "ji" + "yid" // Yiddish (old)
+ "jv" + "jav" // Javanese
+ "ka" + "kat" // Georgian
+ "kg" + "kon" // Kongo
+ "ki" + "kik" // Kikuyu
+ "kj" + "kua" // Kwanyama
+ "kk" + "kaz" // Kazakh
+ "kl" + "kal" // Greenlandic
+ "km" + "khm" // Central Khmer
+ "kn" + "kan" // Kannada
+ "ko" + "kor" // Korean
+ "kr" + "kau" // Kanuri
+ "ks" + "kas" // Kashmiri
+ "ku" + "kur" // Kurdish
+ "kv" + "kom" // Komi
+ "kw" + "cor" // Cornish
+ "ky" + "kir" // Kirghiz
+ "la" + "lat" // Latin
+ "lb" + "ltz" // Luxembourgish
+ "lg" + "lug" // Ganda
+ "li" + "lim" // Limburgish
+ "ln" + "lin" // Lingala
+ "lo" + "lao" // Lao
+ "lt" + "lit" // Lithuanian
+ "lu" + "lub" // Luba-Katanga
+ "lv" + "lav" // Latvian
+ "mg" + "mlg" // Malagasy
+ "mh" + "mah" // Marshallese
+ "mi" + "mri" // Maori
+ "mk" + "mkd" // Macedonian
+ "ml" + "mal" // Malayalam
+ "mn" + "mon" // Mongolian
+ "mo" + "mol" // Moldavian
+ "mr" + "mar" // Marathi
+ "ms" + "msa" // Malay
+ "mt" + "mlt" // Maltese
+ "my" + "mya" // Burmese
+ "na" + "nau" // Nauru
+ "nb" + "nob" // Norwegian Bokmål
+ "nd" + "nde" // North Ndebele
+ "ne" + "nep" // Nepali
+ "ng" + "ndo" // Ndonga
+ "nl" + "nld" // Dutch
+ "nn" + "nno" // Norwegian Nynorsk
+ "no" + "nor" // Norwegian
+ "nr" + "nbl" // South Ndebele
+ "nv" + "nav" // Navajo
+ "ny" + "nya" // Nyanja
+ "oc" + "oci" // Occitan (post 1500)
+ "oj" + "oji" // Ojibwa
+ "om" + "orm" // Oromo
+ "or" + "ori" // Oriya
+ "os" + "oss" // Ossetian
+ "pa" + "pan" // Panjabi
+ "pi" + "pli" // Pali
+ "pl" + "pol" // Polish
+ "ps" + "pus" // Pushto
+ "pt" + "por" // Portuguese
+ "qu" + "que" // Quechua
+ "rm" + "roh" // Romansh
+ "rn" + "run" // Rundi
+ "ro" + "ron" // Romanian
+ "ru" + "rus" // Russian
+ "rw" + "kin" // Kinyarwanda
+ "sa" + "san" // Sanskrit
+ "sc" + "srd" // Sardinian
+ "sd" + "snd" // Sindhi
+ "se" + "sme" // Northern Sami
+ "sg" + "sag" // Sango
+ "si" + "sin" // Sinhala
+ "sk" + "slk" // Slovak
+ "sl" + "slv" // Slovenian
+ "sm" + "smo" // Samoan
+ "sn" + "sna" // Shona
+ "so" + "som" // Somali
+ "sq" + "sqi" // Albanian
+ "sr" + "srp" // Serbian
+ "ss" + "ssw" // Swati
+ "st" + "sot" // Southern Sotho
+ "su" + "sun" // Sundanese
+ "sv" + "swe" // Swedish
+ "sw" + "swa" // Swahili
+ "ta" + "tam" // Tamil
+ "te" + "tel" // Telugu
+ "tg" + "tgk" // Tajik
+ "th" + "tha" // Thai
+ "ti" + "tir" // Tigrinya
+ "tk" + "tuk" // Turkmen
+ "tl" + "tgl" // Tagalog
+ "tn" + "tsn" // Tswana
+ "to" + "ton" // Tonga
+ "tr" + "tur" // Turkish
+ "ts" + "tso" // Tsonga
+ "tt" + "tat" // Tatar
+ "tw" + "twi" // Twi
+ "ty" + "tah" // Tahitian
+ "ug" + "uig" // Uighur
+ "uk" + "ukr" // Ukrainian
+ "ur" + "urd" // Urdu
+ "uz" + "uzb" // Uzbek
+ "ve" + "ven" // Venda
+ "vi" + "vie" // Vietnamese
+ "vo" + "vol" // Volapük
+ "wa" + "wln" // Walloon
+ "wo" + "wol" // Wolof
+ "xh" + "xho" // Xhosa
+ "yi" + "yid" // Yiddish
+ "yo" + "yor" // Yoruba
+ "za" + "zha" // Zhuang
+ "zh" + "zho" // Chinese
+ "zu" + "zul" // Zulu
;
/**
* The 2- and 3-letter ISO 3166 country codes.
*/
private static final String isoCountryTable =
"AD" + "AND" // Andorra, Principality of
+ "AE" + "ARE" // United Arab Emirates
+ "AF" + "AFG" // Afghanistan
+ "AG" + "ATG" // Antigua and Barbuda
+ "AI" + "AIA" // Anguilla
+ "AL" + "ALB" // Albania, People's Socialist Republic of
+ "AM" + "ARM" // Armenia
// + "AN" + "ANT" // Netherlands Antilles
+ "AO" + "AGO" // Angola, Republic of
+ "AQ" + "ATA" // Antarctica (the territory South of 60 deg S)
+ "AR" + "ARG" // Argentina, Argentine Republic
+ "AS" + "ASM" // American Samoa
+ "AT" + "AUT" // Austria, Republic of
+ "AU" + "AUS" // Australia, Commonwealth of
+ "AW" + "ABW" // Aruba
+ "AX" + "ALA" // Åland Islands
+ "AZ" + "AZE" // Azerbaijan, Republic of
+ "BA" + "BIH" // Bosnia and Herzegovina
+ "BB" + "BRB" // Barbados
+ "BD" + "BGD" // Bangladesh, People's Republic of
+ "BE" + "BEL" // Belgium, Kingdom of
+ "BF" + "BFA" // Burkina Faso
+ "BG" + "BGR" // Bulgaria, People's Republic of
+ "BH" + "BHR" // Bahrain, Kingdom of
+ "BI" + "BDI" // Burundi, Republic of
+ "BJ" + "BEN" // Benin, People's Republic of
+ "BL" + "BLM" // Saint Barthélemy
+ "BM" + "BMU" // Bermuda
+ "BN" + "BRN" // Brunei Darussalam
+ "BO" + "BOL" // Bolivia, Plurinational State of
+ "BQ" + "BES" // Bonaire, Sint Eustatius and Saba
+ "BR" + "BRA" // Brazil, Federative Republic of
+ "BS" + "BHS" // Bahamas, Commonwealth of the
+ "BT" + "BTN" // Bhutan, Kingdom of
+ "BV" + "BVT" // Bouvet Island (Bouvetoya)
+ "BW" + "BWA" // Botswana, Republic of
+ "BY" + "BLR" // Belarus
+ "BZ" + "BLZ" // Belize
+ "CA" + "CAN" // Canada
+ "CC" + "CCK" // Cocos (Keeling) Islands
+ "CD" + "COD" // Congo, Democratic Republic of
+ "CF" + "CAF" // Central African Republic
+ "CG" + "COG" // Congo, People's Republic of
+ "CH" + "CHE" // Switzerland, Swiss Confederation
+ "CI" + "CIV" // Cote D'Ivoire, Ivory Coast, Republic of the
+ "CK" + "COK" // Cook Islands
+ "CL" + "CHL" // Chile, Republic of
+ "CM" + "CMR" // Cameroon, United Republic of
+ "CN" + "CHN" // China, People's Republic of
+ "CO" + "COL" // Colombia, Republic of
+ "CR" + "CRI" // Costa Rica, Republic of
// + "CS" + "SCG" // Serbia and Montenegro
+ "CU" + "CUB" // Cuba, Republic of
+ "CV" + "CPV" // Cape Verde, Republic of
+ "CW" + "CUW" // Curaçao
+ "CX" + "CXR" // Christmas Island
+ "CY" + "CYP" // Cyprus, Republic of
+ "CZ" + "CZE" // Czech Republic
+ "DE" + "DEU" // Germany
+ "DJ" + "DJI" // Djibouti, Republic of
+ "DK" + "DNK" // Denmark, Kingdom of
+ "DM" + "DMA" // Dominica, Commonwealth of
+ "DO" + "DOM" // Dominican Republic
+ "DZ" + "DZA" // Algeria, People's Democratic Republic of
+ "EC" + "ECU" // Ecuador, Republic of
+ "EE" + "EST" // Estonia
+ "EG" + "EGY" // Egypt, Arab Republic of
+ "EH" + "ESH" // Western Sahara
+ "ER" + "ERI" // Eritrea, State of
+ "ES" + "ESP" // Spain, Spanish State
+ "ET" + "ETH" // Ethiopia
+ "FI" + "FIN" // Finland, Republic of
+ "FJ" + "FJI" // Fiji, Republic of
+ "FK" + "FLK" // Falkland Islands (Malvinas)
+ "FM" + "FSM" // Micronesia, Federated States of
+ "FO" + "FRO" // Faeroe Islands
+ "FR" + "FRA" // France, French Republic
+ "GA" + "GAB" // Gabon, Gabonese Republic
+ "GB" + "GBR" // United Kingdom of Great Britain & N. Ireland
+ "GD" + "GRD" // Grenada
+ "GE" + "GEO" // Georgia
+ "GF" + "GUF" // French Guiana
+ "GG" + "GGY" // Guernsey, Bailiwick of
+ "GH" + "GHA" // Ghana, Republic of
+ "GI" + "GIB" // Gibraltar
+ "GL" + "GRL" // Greenland
+ "GM" + "GMB" // Gambia, Republic of the
+ "GN" + "GIN" // Guinea, Revolutionary People's Rep'c of
+ "GP" + "GLP" // Guadaloupe
+ "GQ" + "GNQ" // Equatorial Guinea, Republic of
+ "GR" + "GRC" // Greece, Hellenic Republic
+ "GS" + "SGS" // South Georgia and the South Sandwich Islands
+ "GT" + "GTM" // Guatemala, Republic of
+ "GU" + "GUM" // Guam
+ "GW" + "GNB" // Guinea-Bissau, Republic of
+ "GY" + "GUY" // Guyana, Republic of
+ "HK" + "HKG" // Hong Kong, Special Administrative Region of China
+ "HM" + "HMD" // Heard and McDonald Islands
+ "HN" + "HND" // Honduras, Republic of
+ "HR" + "HRV" // Hrvatska (Croatia)
+ "HT" + "HTI" // Haiti, Republic of
+ "HU" + "HUN" // Hungary
+ "ID" + "IDN" // Indonesia, Republic of
+ "IE" + "IRL" // Ireland
+ "IL" + "ISR" // Israel, State of
+ "IM" + "IMN" // Isle of Man
+ "IN" + "IND" // India, Republic of
+ "IO" + "IOT" // British Indian Ocean Territory (Chagos Archipelago)
+ "IQ" + "IRQ" // Iraq, Republic of
+ "IR" + "IRN" // Iran, Islamic Republic of
+ "IS" + "ISL" // Iceland, Republic of
+ "IT" + "ITA" // Italy, Italian Republic
+ "JE" + "JEY" // Jersey, Bailiwick of
+ "JM" + "JAM" // Jamaica
+ "JO" + "JOR" // Jordan, Hashemite Kingdom of
+ "JP" + "JPN" // Japan
+ "KE" + "KEN" // Kenya, Republic of
+ "KG" + "KGZ" // Kyrgyz Republic
+ "KH" + "KHM" // Cambodia, Kingdom of
+ "KI" + "KIR" // Kiribati, Republic of
+ "KM" + "COM" // Comoros, Union of the
+ "KN" + "KNA" // St. Kitts and Nevis
+ "KP" + "PRK" // Korea, Democratic People's Republic of
+ "KR" + "KOR" // Korea, Republic of
+ "KW" + "KWT" // Kuwait, State of
+ "KY" + "CYM" // Cayman Islands
+ "KZ" + "KAZ" // Kazakhstan, Republic of
+ "LA" + "LAO" // Lao People's Democratic Republic
+ "LB" + "LBN" // Lebanon, Lebanese Republic
+ "LC" + "LCA" // St. Lucia
+ "LI" + "LIE" // Liechtenstein, Principality of
+ "LK" + "LKA" // Sri Lanka, Democratic Socialist Republic of
+ "LR" + "LBR" // Liberia, Republic of
+ "LS" + "LSO" // Lesotho, Kingdom of
+ "LT" + "LTU" // Lithuania
+ "LU" + "LUX" // Luxembourg, Grand Duchy of
+ "LV" + "LVA" // Latvia
+ "LY" + "LBY" // Libya
+ "MA" + "MAR" // Morocco, Kingdom of
+ "MC" + "MCO" // Monaco, Principality of
+ "MD" + "MDA" // Moldova, Republic of
+ "ME" + "MNE" // Montenegro
+ "MF" + "MAF" // Saint Martin (French part)
+ "MG" + "MDG" // Madagascar, Republic of
+ "MH" + "MHL" // Marshall Islands
+ "MK" + "MKD" // Macedonia, the former Yugoslav Republic of
+ "ML" + "MLI" // Mali, Republic of
+ "MM" + "MMR" // Myanmar, Republic of the Union of
+ "MN" + "MNG" // Mongolia, Mongolian People's Republic
+ "MO" + "MAC" // Macao, Special Administrative Region of China
+ "MP" + "MNP" // Northern Mariana Islands
+ "MQ" + "MTQ" // Martinique
+ "MR" + "MRT" // Mauritania, Islamic Republic of
+ "MS" + "MSR" // Montserrat
+ "MT" + "MLT" // Malta, Republic of
+ "MU" + "MUS" // Mauritius
+ "MV" + "MDV" // Maldives, Republic of
+ "MW" + "MWI" // Malawi, Republic of
+ "MX" + "MEX" // Mexico, United Mexican States
+ "MY" + "MYS" // Malaysia
+ "MZ" + "MOZ" // Mozambique, People's Republic of
+ "NA" + "NAM" // Namibia
+ "NC" + "NCL" // New Caledonia
+ "NE" + "NER" // Niger, Republic of the
+ "NF" + "NFK" // Norfolk Island
+ "NG" + "NGA" // Nigeria, Federal Republic of
+ "NI" + "NIC" // Nicaragua, Republic of
+ "NL" + "NLD" // Netherlands, Kingdom of the
+ "NO" + "NOR" // Norway, Kingdom of
+ "NP" + "NPL" // Nepal, Federal Democratic Republic of
+ "NR" + "NRU" // Nauru, Republic of
+ "NU" + "NIU" // Niue
+ "NZ" + "NZL" // New Zealand
+ "OM" + "OMN" // Oman, Sultanate of
+ "PA" + "PAN" // Panama, Republic of
+ "PE" + "PER" // Peru, Republic of
+ "PF" + "PYF" // French Polynesia
+ "PG" + "PNG" // Papua New Guinea
+ "PH" + "PHL" // Philippines, Republic of the
+ "PK" + "PAK" // Pakistan, Islamic Republic of
+ "PL" + "POL" // Poland, Republic of Poland
+ "PM" + "SPM" // St. Pierre and Miquelon
+ "PN" + "PCN" // Pitcairn Island
+ "PR" + "PRI" // Puerto Rico
+ "PS" + "PSE" // Palestine, State of
+ "PT" + "PRT" // Portugal, Portuguese Republic
+ "PW" + "PLW" // Palau
+ "PY" + "PRY" // Paraguay, Republic of
+ "QA" + "QAT" // Qatar, State of
+ "RE" + "REU" // Reunion
+ "RO" + "ROU" // Romania, Socialist Republic of
+ "RS" + "SRB" // Serbia, Republic of
+ "RU" + "RUS" // Russian Federation
+ "RW" + "RWA" // Rwanda, Rwandese Republic
+ "SA" + "SAU" // Saudi Arabia, Kingdom of
+ "SB" + "SLB" // Solomon Islands
+ "SC" + "SYC" // Seychelles, Republic of
+ "SD" + "SDN" // Sudan, Republic of the
+ "SE" + "SWE" // Sweden, Kingdom of
+ "SG" + "SGP" // Singapore, Republic of
+ "SH" + "SHN" // Saint Helena, Ascension and Tristan da Cunha
+ "SI" + "SVN" // Slovenia
+ "SJ" + "SJM" // Svalbard & Jan Mayen Islands
+ "SK" + "SVK" // Slovakia (Slovak Republic)
+ "SL" + "SLE" // Sierra Leone, Republic of
+ "SM" + "SMR" // San Marino, Republic of
+ "SN" + "SEN" // Senegal, Republic of
+ "SO" + "SOM" // Somalia, Somali Republic
+ "SR" + "SUR" // Suriname, Republic of
+ "SS" + "SSD" // South Sudan, Republic of
+ "ST" + "STP" // Sao Tome and Principe, Democratic Republic of
+ "SV" + "SLV" // El Salvador, Republic of
+ "SX" + "SXM" // Sint Maarten (Dutch part)
+ "SY" + "SYR" // Syrian Arab Republic
+ "SZ" + "SWZ" // Swaziland, Kingdom of
+ "TC" + "TCA" // Turks and Caicos Islands
+ "TD" + "TCD" // Chad, Republic of
+ "TF" + "ATF" // French Southern Territories
+ "TG" + "TGO" // Togo, Togolese Republic
+ "TH" + "THA" // Thailand, Kingdom of
+ "TJ" + "TJK" // Tajikistan
+ "TK" + "TKL" // Tokelau (Tokelau Islands)
+ "TL" + "TLS" // Timor-Leste, Democratic Republic of
+ "TM" + "TKM" // Turkmenistan
+ "TN" + "TUN" // Tunisia, Republic of
+ "TO" + "TON" // Tonga, Kingdom of
+ "TR" + "TUR" // Turkey, Republic of
+ "TT" + "TTO" // Trinidad and Tobago, Republic of
+ "TV" + "TUV" // Tuvalu
+ "TW" + "TWN" // Taiwan, Province of China
+ "TZ" + "TZA" // Tanzania, United Republic of
+ "UA" + "UKR" // Ukraine
+ "UG" + "UGA" // Uganda, Republic of
+ "UM" + "UMI" // United States Minor Outlying Islands
+ "US" + "USA" // United States of America
+ "UY" + "URY" // Uruguay, Eastern Republic of
+ "UZ" + "UZB" // Uzbekistan
+ "VA" + "VAT" // Holy See (Vatican City State)
+ "VC" + "VCT" // St. Vincent and the Grenadines
+ "VE" + "VEN" // Venezuela, Bolivarian Republic of
+ "VG" + "VGB" // British Virgin Islands
+ "VI" + "VIR" // US Virgin Islands
+ "VN" + "VNM" // Viet Nam, Socialist Republic of
+ "VU" + "VUT" // Vanuatu
+ "WF" + "WLF" // Wallis and Futuna Islands
+ "WS" + "WSM" // Samoa, Independent State of
+ "YE" + "YEM" // Yemen
+ "YT" + "MYT" // Mayotte
+ "ZA" + "ZAF" // South Africa, Republic of
+ "ZM" + "ZMB" // Zambia, Republic of
+ "ZW" + "ZWE" // Zimbabwe
;
/**
* Array to hold country codes for ISO3166-3.
*/
private static final String[] ISO3166_3 = {
"AIDJ", "ANHH", "BQAQ", "BUMM", "BYAA", "CSHH", "CSXX", "CTKI", "DDDE",
"DYBJ", "FQHH", "FXFR", "GEHH", "HVBF", "JTUM", "MIUM", "NHVU", "NQAQ",
"NTHH", "PCHH", "PUUM", "PZPA", "RHZW", "SKIN", "SUHH", "TPTL", "VDVN",
"WKUM", "YDYE", "YUCS", "ZRCD"
};
static String getISO3LangCode(String language) {
return getISO3Code(language, isoLanguageTable);
}
static String getISO3CtryCode(String country) {
return getISO3Code(country, isoCountryTable);
}
private static String getISO3Code(String iso2Code, String table) {
int codeLength = iso2Code.length();
if (codeLength == 0) {
return "";
}
int tableLength = table.length();
int index = tableLength;
if (codeLength == 2) {
char c1 = iso2Code.charAt(0);
char c2 = iso2Code.charAt(1);
for (index = 0; index < tableLength; index += 5) {
if (table.charAt(index) == c1
&& table.charAt(index + 1) == c2) {
break;
}
}
}
return index < tableLength ? table.substring(index + 2, index + 5) : null;
}
/**
* This method computes an array of alpha-2 codes from either ISO639 or
* ISO3166.
*/
private static String[] getISO2Table(String table) {
int len = table.length() / 5;
String[] isoTable = new String[len];
for (int i = 0, j = 0; i < len; i++, j += 5) {
isoTable[i] = table.substring(j, j + 2);
}
return isoTable;
}
/**
* This method computes a set of ISO3166-1 alpha-3 country codes from
* existing isoCountryTable.
*/
private static Set<String> computeISO3166_1Alpha3Countries() {
int tableLength = isoCountryTable.length();
String[] isoTable = new String[tableLength / 5];
for (int i = 0, index = 0; index < tableLength; i++, index += 5) {
isoTable[i] = isoCountryTable.substring(index + 2, index + 5);
}
return Set.of(isoTable);
}
private LocaleISOData() {}
}