forked from gnustep/libs-corebase
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CFLocaleIdentifier.c
2224 lines (2087 loc) · 133 KB
/
CFLocaleIdentifier.c
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
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2015 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
CFLocaleIdentifier.c
Copyright (c) 2002-2014, Apple Inc. All rights reserved.
Responsibility: David Smith
CFLocaleIdentifier.c defines
- enum value kLocaleIdentifierCStringMax
- structs KeyStringToResultString, SpecialCaseUpdates
and provides the following data for the functions
CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes,
CFLocaleCreateCanonicalLocaleIdentifierFromString
CFLocaleCreateCanonicalLanguageIdentifierFromString
1. static const char * regionCodeToLocaleString[]; enum kNumRegionCodeToLocaleString;
map RegionCode 0..kNumRegionCodeToLocaleString-1 to canonical locale string
2. static const char * langCodeToLocaleString[]; enum kNumLangCodeToLocaleString;
map LangCode 0..kNumLangCodeToLocaleString-1 to canonical locale string
3. static const KeyStringToResultString oldAppleLocaleToCanonical[]; enum kNumOldAppleLocaleToCanonical;
map old Apple string oldAppleLocaleToCanonical[n].key
to canonical locale string oldAppleLocaleToCanonical[n].result
for n = 0..kNumOldAppleLocaleToCanonical-1
4. static const KeyStringToResultString localeStringPrefixToCanonical[]; enum kNumLocaleStringPrefixToCanonical;
map non-canonical language prefix (3-letter, obsolete) localeStringPrefixToCanonical[].key
to updated replacement localeStringPrefixToCanonical[].result
for n = 0..kNumLocaleStringPrefixToCanonical-1
5. static const SpecialCaseUpdates specialCases[];
various special cases for updating region codes, or for updating language codes based on region codes
6. static const KeyStringToResultString localeStringRegionToDefaults[]; enum kNumLocaleStringRegionToDefaults;
map locale string region tag localeStringRegionToDefaults[n].key
to default substrings to delete localeStringRegionToDefaults[n].result
for n = 0..kNumLocaleStringRegionToDefaults-1
7. static const KeyStringToResultString localeStringPrefixToDefaults[]; enum kNumLocaleStringPrefixToDefaults;
map locale string initial part localeStringPrefixToDefaults[n].key
to default substrings to delete localeStringPrefixToDefaults[n].result
for n = 0..kNumLocaleStringPrefixToDefaults-1
8. static const KeyStringToResultString appleLocaleToLanguageString[]; enum kNumAppleLocaleToLanguageString;
map Apple locale string appleLocaleToLanguageString[].key
to equivalent language string appleLocaleToLanguageString[].result
for n = 0..kNumAppleLocaleToLanguageString-1
*/
#include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFCalendar.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED || DEPLOYMENT_TARGET_WINDOWS || DEPLOYMENT_TARGET_LINUX
#include <unicode/uloc.h>
#else
#define ULOC_KEYWORD_SEPARATOR '@'
#define ULOC_FULLNAME_CAPACITY 56
#define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
#endif
#include "CFInternal.h"
#include "CFLocaleInternal.h"
// Max byte length of locale identifier (ASCII) as C string, including terminating null byte
enum {
kLocaleIdentifierCStringMax = ULOC_FULLNAME_CAPACITY + ULOC_KEYWORD_AND_VALUES_CAPACITY // currently 56 + 100
};
// KeyStringToResultString struct used in data tables for CFLocaleCreateCanonicalLocaleIdentifierFromString
struct KeyStringToResultString {
const char * key;
const char * result;
};
typedef struct KeyStringToResultString KeyStringToResultString;
// SpecialCaseUpdates struct used in data tables for CFLocaleCreateCanonicalLocaleIdentifierFromString
struct SpecialCaseUpdates {
const char * lang;
const char * reg1;
const char * update1;
const char * reg2;
const char * update2;
};
typedef struct SpecialCaseUpdates SpecialCaseUpdates;
static const char * const regionCodeToLocaleString[] = {
// map RegionCode (array index) to canonical locale string
//
// canon. string region code; language code; [comment] [ # __CFBundleLocaleAbbreviationsArray
// -------- ------------ ------------------ ------------ -------- string, if different ]
"en_US", // 0 verUS; 0 langEnglish;
"fr_FR", // 1 verFrance; 1 langFrench;
"en_GB", // 2 verBritain; 0 langEnglish;
"de_DE", // 3 verGermany; 2 langGerman;
"it_IT", // 4 verItaly; 3 langItalian;
"nl_NL", // 5 verNetherlands; 4 langDutch;
"nl_BE", // 6 verFlemish; 34 langFlemish (redundant, =Dutch);
"sv_SE", // 7 verSweden; 5 langSwedish;
"es_ES", // 8 verSpain; 6 langSpanish;
"da_DK", // 9 verDenmark; 7 langDanish;
"pt_PT", // 10 verPortugal; 8 langPortuguese;
"fr_CA", // 11 verFrCanada; 1 langFrench;
"nb_NO", // 12 verNorway; 9 langNorwegian (Bokmal); # "no_NO"
"he_IL", // 13 verIsrael; 10 langHebrew;
"ja_JP", // 14 verJapan; 11 langJapanese;
"en_AU", // 15 verAustralia; 0 langEnglish;
"ar", // 16 verArabic; 12 langArabic;
"fi_FI", // 17 verFinland; 13 langFinnish;
"fr_CH", // 18 verFrSwiss; 1 langFrench;
"de_CH", // 19 verGrSwiss; 2 langGerman;
"el_GR", // 20 verGreece; 14 langGreek (modern)-Grek-mono;
"is_IS", // 21 verIceland; 15 langIcelandic;
"mt_MT", // 22 verMalta; 16 langMaltese;
"el_CY", // 23 verCyprus; 14 langGreek?; el or tr? guess el # ""
"tr_TR", // 24 verTurkey; 17 langTurkish;
"hr_HR", // 25 verYugoCroatian; 18 langCroatian; * one-way mapping -> verCroatia
"nl_NL", // 26 KCHR, Netherlands; 4 langDutch; * one-way mapping
"nl_BE", // 27 KCHR, verFlemish; 34 langFlemish; * one-way mapping
"_CA", // 28 KCHR, Canada-en/fr?; -1 none; * one-way mapping # "en_CA"
"_CA", // 29 KCHR, Canada-en/fr?; -1 none; * one-way mapping # "en_CA"
"pt_PT", // 30 KCHR, Portugal; 8 langPortuguese; * one-way mapping
"nb_NO", // 31 KCHR, Norway; 9 langNorwegian (Bokmal); * one-way mapping # "no_NO"
"da_DK", // 32 KCHR, Denmark; 7 langDanish; * one-way mapping
"hi_IN", // 33 verIndiaHindi; 21 langHindi;
"ur_PK", // 34 verPakistanUrdu; 20 langUrdu;
"tr_TR", // 35 verTurkishModified; 17 langTurkish; * one-way mapping
"it_CH", // 36 verItalianSwiss; 3 langItalian;
"en_001", // 37 verInternational; 0 langEnglish; ASCII only # "en"
NULL, // 38 *unassigned; -1 none; * one-way mapping # ""
"ro_RO", // 39 verRomania; 37 langRomanian;
"grc", // 40 verGreekAncient; 148 langGreekAncient -Grek-poly; # "el_GR"
"lt_LT", // 41 verLithuania; 24 langLithuanian;
"pl_PL", // 42 verPoland; 25 langPolish;
"hu_HU", // 43 verHungary; 26 langHungarian;
"et_EE", // 44 verEstonia; 27 langEstonian;
"lv_LV", // 45 verLatvia; 28 langLatvian;
"se", // 46 verSami; 29 langSami;
"fo_FO", // 47 verFaroeIsl; 30 langFaroese;
"fa_IR", // 48 verIran; 31 langFarsi/Persian;
"ru_RU", // 49 verRussia; 32 langRussian;
"ga_IE", // 50 verIreland; 35 langIrishGaelic (no dots);
"ko_KR", // 51 verKorea; 23 langKorean;
"zh_CN", // 52 verChina; 33 langSimpChinese;
"zh_TW", // 53 verTaiwan; 19 langTradChinese;
"th_TH", // 54 verThailand; 22 langThai;
"und", // 55 verScriptGeneric; -1 none; # "" // <1.9>
"cs_CZ", // 56 verCzech; 38 langCzech;
"sk_SK", // 57 verSlovak; 39 langSlovak;
"und", // 58 verEastAsiaGeneric; -1 none; * one-way mapping # "" // <1.9>
"hu_HU", // 59 verMagyar; 26 langHungarian; * one-way mapping -> verHungary
"bn", // 60 verBengali; 67 langBengali; _IN or _BD? guess generic
"be_BY", // 61 verBelarus; 46 langBelorussian;
"uk_UA", // 62 verUkraine; 45 langUkrainian;
NULL, // 63 *unused; -1 none; * one-way mapping # ""
"el_GR", // 64 verGreeceAlt; 14 langGreek (modern)-Grek-mono; * one-way mapping
"sr_RS", // 65 verSerbian; 42 langSerbian -Cyrl; // <1.18>
"sl_SI", // 66 verSlovenian; 40 langSlovenian;
"mk_MK", // 67 verMacedonian; 43 langMacedonian;
"hr_HR", // 68 verCroatia; 18 langCroatian;
NULL, // 69 *unused; -1 none; * one-way mapping # ""
"de-1996", // 70 verGermanReformed; 2 langGerman; 1996 orthogr. # "de_DE"
"pt_BR", // 71 verBrazil; 8 langPortuguese;
"bg_BG", // 72 verBulgaria; 44 langBulgarian;
"ca_ES", // 73 verCatalonia; 130 langCatalan;
"mul", // 74 verMultilingual; -1 none; # ""
"gd", // 75 verScottishGaelic; 144 langScottishGaelic;
"gv", // 76 verManxGaelic; 145 langManxGaelic;
"br", // 77 verBreton; 142 langBreton;
"iu_CA", // 78 verNunavut; 143 langInuktitut -Cans;
"cy", // 79 verWelsh; 128 langWelsh;
"_CA", // 80 KCHR, Canada-en/fr?; -1 none; * one-way mapping # "en_CA"
"ga-Latg_IE", // 81 verIrishGaelicScrip; 146 langIrishGaelicScript -dots; # "ga_IE" // <xx>
"en_CA", // 82 verEngCanada; 0 langEnglish;
"dz_BT", // 83 verBhutan; 137 langDzongkha;
"hy_AM", // 84 verArmenian; 51 langArmenian;
"ka_GE", // 85 verGeorgian; 52 langGeorgian;
"es_419", // 86 verSpLatinAmerica; 6 langSpanish; # "es"
"es_ES", // 87 KCHR, Spain; 6 langSpanish; * one-way mapping
"to_TO", // 88 verTonga; 147 langTongan;
"pl_PL", // 89 KCHR, Poland; 25 langPolish; * one-way mapping
"ca_ES", // 90 KCHR, Catalonia; 130 langCatalan; * one-way mapping
"fr_001", // 91 verFrenchUniversal; 1 langFrench;
"de_AT", // 92 verAustria; 2 langGerman;
"es_419", // 93 > verSpLatinAmerica; 6 langSpanish; * one-way mapping # "es"
"gu_IN", // 94 verGujarati; 69 langGujarati;
"pa", // 95 verPunjabi; 70 langPunjabi; _IN or _PK? guess generic
"ur_IN", // 96 verIndiaUrdu; 20 langUrdu;
"vi_VN", // 97 verVietnam; 80 langVietnamese;
"fr_BE", // 98 verFrBelgium; 1 langFrench;
"uz_UZ", // 99 verUzbek; 47 langUzbek;
"en_SG", // 100 verSingapore; 0 langEnglish?; en, zh, or ms? guess en # ""
"nn_NO", // 101 verNynorsk; 151 langNynorsk; # ""
"af_ZA", // 102 verAfrikaans; 141 langAfrikaans;
"eo", // 103 verEsperanto; 94 langEsperanto;
"mr_IN", // 104 verMarathi; 66 langMarathi;
"bo", // 105 verTibetan; 63 langTibetan;
"ne_NP", // 106 verNepal; 64 langNepali;
"kl", // 107 verGreenland; 149 langGreenlandic;
"en_IE", // 108 verIrelandEnglish; 0 langEnglish; # (no entry)
};
enum {
kNumRegionCodeToLocaleString = sizeof(regionCodeToLocaleString)/sizeof(char *)
};
static const char * const langCodeToLocaleString[] = {
// map LangCode (array index) to canonical locale string
//
// canon. string language code; [ comment] [ # __CFBundleLanguageAbbreviationsArray
// -------- -------------- ---------- -------- string, if different ]
"en", // 0 langEnglish;
"fr", // 1 langFrench;
"de", // 2 langGerman;
"it", // 3 langItalian;
"nl", // 4 langDutch;
"sv", // 5 langSwedish;
"es", // 6 langSpanish;
"da", // 7 langDanish;
"pt", // 8 langPortuguese;
"nb", // 9 langNorwegian (Bokmal); # "no"
"he", // 10 langHebrew -Hebr;
"ja", // 11 langJapanese -Jpan;
"ar", // 12 langArabic -Arab;
"fi", // 13 langFinnish;
"el", // 14 langGreek (modern)-Grek-mono;
"is", // 15 langIcelandic;
"mt", // 16 langMaltese -Latn;
"tr", // 17 langTurkish -Latn;
"hr", // 18 langCroatian;
"zh-Hant", // 19 langTradChinese; # "zh"
"ur", // 20 langUrdu -Arab;
"hi", // 21 langHindi -Deva;
"th", // 22 langThai -Thai;
"ko", // 23 langKorean -Hang;
"lt", // 24 langLithuanian;
"pl", // 25 langPolish;
"hu", // 26 langHungarian;
"et", // 27 langEstonian;
"lv", // 28 langLatvian;
"se", // 29 langSami;
"fo", // 30 langFaroese;
"fa", // 31 langFarsi/Persian -Arab;
"ru", // 32 langRussian -Cyrl;
"zh-Hans", // 33 langSimpChinese; # "zh"
"nl-BE", // 34 langFlemish (redundant, =Dutch); # "nl"
"ga", // 35 langIrishGaelic (no dots);
"sq", // 36 langAlbanian; no region codes
"ro", // 37 langRomanian;
"cs", // 38 langCzech;
"sk", // 39 langSlovak;
"sl", // 40 langSlovenian;
"yi", // 41 langYiddish -Hebr; no region codes
"sr", // 42 langSerbian -Cyrl;
"mk", // 43 langMacedonian -Cyrl;
"bg", // 44 langBulgarian -Cyrl;
"uk", // 45 langUkrainian -Cyrl;
"be", // 46 langBelorussian -Cyrl;
"uz", // 47 langUzbek -Cyrl; also -Latn, -Arab
"kk", // 48 langKazakh -Cyrl; no region codes; also -Latn, -Arab
"az-Cyrl", // 49 langAzerbaijani -Cyrl; no region codes # "az"
"az-Arab", // 50 langAzerbaijanAr -Arab; no region codes # "az"
"hy", // 51 langArmenian -Armn;
"ka", // 52 langGeorgian -Geor;
"mo", // 53 langMoldavian -Cyrl; no region codes
"ky", // 54 langKirghiz -Cyrl; no region codes; also -Latn, -Arab
"tg", // 55 langTajiki -Cyrl; no region codes; also -Latn, -Arab
"tk-Cyrl", // 56 langTurkmen -Cyrl; no region codes; also -Latn, -Arab
"mn-Mong", // 57 langMongolian -Mong; no region codes # "mn"
"mn", // 58 langMongolianCyr -Cyrl; no region codes # "mn"
"ps", // 59 langPashto -Arab; no region codes
"ku", // 60 langKurdish -Arab; no region codes
"ks", // 61 langKashmiri -Arab; no region codes
"sd", // 62 langSindhi -Arab; no region codes
"bo", // 63 langTibetan -Tibt;
"ne", // 64 langNepali -Deva;
"sa", // 65 langSanskrit -Deva; no region codes
"mr", // 66 langMarathi -Deva;
"bn", // 67 langBengali -Beng;
"as", // 68 langAssamese -Beng; no region codes
"gu", // 69 langGujarati -Gujr;
"pa", // 70 langPunjabi -Guru;
"or", // 71 langOriya -Orya; no region codes
"ml", // 72 langMalayalam -Mlym; no region codes
"kn", // 73 langKannada -Knda; no region codes
"ta", // 74 langTamil -Taml; no region codes
"te", // 75 langTelugu -Telu; no region codes
"si", // 76 langSinhalese -Sinh; no region codes
"my", // 77 langBurmese -Mymr; no region codes
"km", // 78 langKhmer -Khmr; no region codes
"lo", // 79 langLao -Laoo; no region codes
"vi", // 80 langVietnamese -Latn;
"id", // 81 langIndonesian -Latn; no region codes
"fil", // 82 langTagalog -Latn; no region codes
"ms", // 83 langMalayRoman -Latn; no region codes # "ms"
"ms-Arab", // 84 langMalayArabic -Arab; no region codes # "ms"
"am", // 85 langAmharic -Ethi; no region codes
"ti", // 86 langTigrinya -Ethi; no region codes
"om", // 87 langOromo -Ethi; no region codes
"so", // 88 langSomali -Latn; no region codes
"sw", // 89 langSwahili -Latn; no region codes
"rw", // 90 langKinyarwanda -Latn; no region codes
"rn", // 91 langRundi -Latn; no region codes
"ny", // 92 langNyanja/Chewa -Latn; no region codes # ""
"mg", // 93 langMalagasy -Latn; no region codes
"eo", // 94 langEsperanto -Latn;
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, // 95 to 105 (gap)
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, // 106 to 116 (gap)
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, // 107 to 117 (gap)
"cy", // 128 langWelsh -Latn;
"eu", // 129 langBasque -Latn; no region codes
"ca", // 130 langCatalan -Latn;
"la", // 131 langLatin -Latn; no region codes
"qu", // 132 langQuechua -Latn; no region codes
"gn", // 133 langGuarani -Latn; no region codes
"ay", // 134 langAymara -Latn; no region codes
"tt-Cyrl", // 135 langTatar -Cyrl; no region codes
"ug", // 136 langUighur -Arab; no region codes
"dz", // 137 langDzongkha -Tibt;
"jv", // 138 langJavaneseRom -Latn; no region codes
"su", // 139 langSundaneseRom -Latn; no region codes
"gl", // 140 langGalician -Latn; no region codes
"af", // 141 langAfrikaans -Latn;
"br", // 142 langBreton -Latn;
"iu", // 143 langInuktitut -Cans;
"gd", // 144 langScottishGaelic;
"gv", // 145 langManxGaelic -Latn;
"ga-Latg", // 146 langIrishGaelicScript -Latn-dots; # "ga" // <xx>
"to", // 147 langTongan -Latn;
"grc", // 148 langGreekAncient -Grek-poly; # "el"
"kl", // 149 langGreenlandic -Latn;
"az", // 150 langAzerbaijanRoman -Latn; no region codes # "az"
"nn", // 151 langNynorsk -Latn; # (no entry)
};
enum {
kNumLangCodeToLocaleString = sizeof(langCodeToLocaleString)/sizeof(char *)
};
static const KeyStringToResultString oldAppleLocaleToCanonical[] = {
// Map obsolete/old-style Apple strings to canonical
// Must be sorted according to how strcmp compares the strings in the first column
//
// non-canonical canonical [ comment ] # source/reason for non-canonical string
// string string
// ------------- ---------
{ "Afrikaans", "af" }, // # __CFBundleLanguageNamesArray
{ "Albanian", "sq" }, // # __CFBundleLanguageNamesArray
{ "Amharic", "am" }, // # __CFBundleLanguageNamesArray
{ "Arabic", "ar" }, // # __CFBundleLanguageNamesArray
{ "Armenian", "hy" }, // # __CFBundleLanguageNamesArray
{ "Assamese", "as" }, // # __CFBundleLanguageNamesArray
{ "Aymara", "ay" }, // # __CFBundleLanguageNamesArray
{ "Azerbaijani", "az" }, // -Arab,-Cyrl,-Latn? # __CFBundleLanguageNamesArray (had 3 entries "Azerbaijani" for "az-Arab", "az-Cyrl", "az-Latn")
{ "Basque", "eu" }, // # __CFBundleLanguageNamesArray
{ "Belarusian", "be" }, // # handle other names
{ "Belorussian", "be" }, // # handle other names
{ "Bengali", "bn" }, // # __CFBundleLanguageNamesArray
{ "Brazilian Portugese", "pt-BR" }, // # from Installer.app Info.plist IFLanguages key, misspelled
{ "Brazilian Portuguese", "pt-BR" }, // # correct spelling for above
{ "Breton", "br" }, // # __CFBundleLanguageNamesArray
{ "Bulgarian", "bg" }, // # __CFBundleLanguageNamesArray
{ "Burmese", "my" }, // # __CFBundleLanguageNamesArray
{ "Byelorussian", "be" }, // # __CFBundleLanguageNamesArray
{ "Catalan", "ca" }, // # __CFBundleLanguageNamesArray
{ "Chewa", "ny" }, // # handle other names
{ "Chichewa", "ny" }, // # handle other names
{ "Chinese", "zh" }, // -Hans,-Hant? # __CFBundleLanguageNamesArray (had 2 entries "Chinese" for "zh-Hant", "zh-Hans")
{ "Chinese, Simplified", "zh-Hans" }, // # from Installer.app Info.plist IFLanguages key
{ "Chinese, Traditional", "zh-Hant" }, // # correct spelling for below
{ "Chinese, Tradtional", "zh-Hant" }, // # from Installer.app Info.plist IFLanguages key, misspelled
{ "Croatian", "hr" }, // # __CFBundleLanguageNamesArray
{ "Czech", "cs" }, // # __CFBundleLanguageNamesArray
{ "Danish", "da" }, // # __CFBundleLanguageNamesArray
{ "Dutch", "nl" }, // # __CFBundleLanguageNamesArray (had 2 entries "Dutch" for "nl", "nl-BE")
{ "Dzongkha", "dz" }, // # __CFBundleLanguageNamesArray
{ "English", "en" }, // # __CFBundleLanguageNamesArray
{ "Esperanto", "eo" }, // # __CFBundleLanguageNamesArray
{ "Estonian", "et" }, // # __CFBundleLanguageNamesArray
{ "Faroese", "fo" }, // # __CFBundleLanguageNamesArray
{ "Farsi", "fa" }, // # __CFBundleLanguageNamesArray
{ "Finnish", "fi" }, // # __CFBundleLanguageNamesArray
{ "Flemish", "nl-BE" }, // # handle other names
{ "French", "fr" }, // # __CFBundleLanguageNamesArray
{ "Galician", "gl" }, // # __CFBundleLanguageNamesArray
{ "Gallegan", "gl" }, // # handle other names
{ "Georgian", "ka" }, // # __CFBundleLanguageNamesArray
{ "German", "de" }, // # __CFBundleLanguageNamesArray
{ "Greek", "el" }, // # __CFBundleLanguageNamesArray (had 2 entries "Greek" for "el", "grc")
{ "Greenlandic", "kl" }, // # __CFBundleLanguageNamesArray
{ "Guarani", "gn" }, // # __CFBundleLanguageNamesArray
{ "Gujarati", "gu" }, // # __CFBundleLanguageNamesArray
{ "Hawaiian", "haw" }, // # handle new languages
{ "Hebrew", "he" }, // # __CFBundleLanguageNamesArray
{ "Hindi", "hi" }, // # __CFBundleLanguageNamesArray
{ "Hungarian", "hu" }, // # __CFBundleLanguageNamesArray
{ "Icelandic", "is" }, // # __CFBundleLanguageNamesArray
{ "Indonesian", "id" }, // # __CFBundleLanguageNamesArray
{ "Inuktitut", "iu" }, // # __CFBundleLanguageNamesArray
{ "Irish", "ga" }, // # __CFBundleLanguageNamesArray (had 2 entries "Irish" for "ga", "ga-dots")
{ "Italian", "it" }, // # __CFBundleLanguageNamesArray
{ "Japanese", "ja" }, // # __CFBundleLanguageNamesArray
{ "Javanese", "jv" }, // # __CFBundleLanguageNamesArray
{ "Kalaallisut", "kl" }, // # handle other names
{ "Kannada", "kn" }, // # __CFBundleLanguageNamesArray
{ "Kashmiri", "ks" }, // # __CFBundleLanguageNamesArray
{ "Kazakh", "kk" }, // # __CFBundleLanguageNamesArray
{ "Khmer", "km" }, // # __CFBundleLanguageNamesArray
{ "Kinyarwanda", "rw" }, // # __CFBundleLanguageNamesArray
{ "Kirghiz", "ky" }, // # __CFBundleLanguageNamesArray
{ "Korean", "ko" }, // # __CFBundleLanguageNamesArray
{ "Kurdish", "ku" }, // # __CFBundleLanguageNamesArray
{ "Lao", "lo" }, // # __CFBundleLanguageNamesArray
{ "Latin", "la" }, // # __CFBundleLanguageNamesArray
{ "Latvian", "lv" }, // # __CFBundleLanguageNamesArray
{ "Lithuanian", "lt" }, // # __CFBundleLanguageNamesArray
{ "Macedonian", "mk" }, // # __CFBundleLanguageNamesArray
{ "Malagasy", "mg" }, // # __CFBundleLanguageNamesArray
{ "Malay", "ms" }, // -Latn,-Arab? # __CFBundleLanguageNamesArray (had 2 entries "Malay" for "ms-Latn", "ms-Arab")
{ "Malayalam", "ml" }, // # __CFBundleLanguageNamesArray
{ "Maltese", "mt" }, // # __CFBundleLanguageNamesArray
{ "Manx", "gv" }, // # __CFBundleLanguageNamesArray
{ "Marathi", "mr" }, // # __CFBundleLanguageNamesArray
{ "Moldavian", "mo" }, // # __CFBundleLanguageNamesArray
{ "Mongolian", "mn" }, // -Mong,-Cyrl? # __CFBundleLanguageNamesArray (had 2 entries "Mongolian" for "mn-Mong", "mn-Cyrl")
{ "Nepali", "ne" }, // # __CFBundleLanguageNamesArray
{ "Norwegian", "nb" }, // # __CFBundleLanguageNamesArray (had "Norwegian" mapping to "no")
{ "Nyanja", "ny" }, // # __CFBundleLanguageNamesArray
{ "Nynorsk", "nn" }, // # handle other names (no entry in __CFBundleLanguageNamesArray)
{ "Oriya", "or" }, // # __CFBundleLanguageNamesArray
{ "Oromo", "om" }, // # __CFBundleLanguageNamesArray
{ "Panjabi", "pa" }, // # handle other names
{ "Pashto", "ps" }, // # __CFBundleLanguageNamesArray
{ "Persian", "fa" }, // # handle other names
{ "Polish", "pl" }, // # __CFBundleLanguageNamesArray
{ "Portuguese", "pt" }, // # __CFBundleLanguageNamesArray
{ "Portuguese, Brazilian", "pt-BR" }, // # handle other names
{ "Punjabi", "pa" }, // # __CFBundleLanguageNamesArray
{ "Pushto", "ps" }, // # handle other names
{ "Quechua", "qu" }, // # __CFBundleLanguageNamesArray
{ "Romanian", "ro" }, // # __CFBundleLanguageNamesArray
{ "Ruanda", "rw" }, // # handle other names
{ "Rundi", "rn" }, // # __CFBundleLanguageNamesArray
{ "Russian", "ru" }, // # __CFBundleLanguageNamesArray
{ "Sami", "se" }, // # __CFBundleLanguageNamesArray
{ "Sanskrit", "sa" }, // # __CFBundleLanguageNamesArray
{ "Scottish", "gd" }, // # __CFBundleLanguageNamesArray
{ "Serbian", "sr" }, // # __CFBundleLanguageNamesArray
{ "Simplified Chinese", "zh-Hans" }, // # handle other names
{ "Sindhi", "sd" }, // # __CFBundleLanguageNamesArray
{ "Sinhalese", "si" }, // # __CFBundleLanguageNamesArray
{ "Slovak", "sk" }, // # __CFBundleLanguageNamesArray
{ "Slovenian", "sl" }, // # __CFBundleLanguageNamesArray
{ "Somali", "so" }, // # __CFBundleLanguageNamesArray
{ "Spanish", "es" }, // # __CFBundleLanguageNamesArray
{ "Sundanese", "su" }, // # __CFBundleLanguageNamesArray
{ "Swahili", "sw" }, // # __CFBundleLanguageNamesArray
{ "Swedish", "sv" }, // # __CFBundleLanguageNamesArray
{ "Tagalog", "fil" }, // # __CFBundleLanguageNamesArray
{ "Tajik", "tg" }, // # handle other names
{ "Tajiki", "tg" }, // # __CFBundleLanguageNamesArray
{ "Tamil", "ta" }, // # __CFBundleLanguageNamesArray
{ "Tatar", "tt" }, // # __CFBundleLanguageNamesArray
{ "Telugu", "te" }, // # __CFBundleLanguageNamesArray
{ "Thai", "th" }, // # __CFBundleLanguageNamesArray
{ "Tibetan", "bo" }, // # __CFBundleLanguageNamesArray
{ "Tigrinya", "ti" }, // # __CFBundleLanguageNamesArray
{ "Tongan", "to" }, // # __CFBundleLanguageNamesArray
{ "Traditional Chinese", "zh-Hant" }, // # handle other names
{ "Turkish", "tr" }, // # __CFBundleLanguageNamesArray
{ "Turkmen", "tk" }, // # __CFBundleLanguageNamesArray
{ "Uighur", "ug" }, // # __CFBundleLanguageNamesArray
{ "Ukrainian", "uk" }, // # __CFBundleLanguageNamesArray
{ "Urdu", "ur" }, // # __CFBundleLanguageNamesArray
{ "Uzbek", "uz" }, // # __CFBundleLanguageNamesArray
{ "Vietnamese", "vi" }, // # __CFBundleLanguageNamesArray
{ "Welsh", "cy" }, // # __CFBundleLanguageNamesArray
{ "Yiddish", "yi" }, // # __CFBundleLanguageNamesArray
{ "ar_??", "ar" }, // # from old MapScriptInfoAndISOCodes
{ "az.Ar", "az-Arab" }, // # from old LocaleRefGetPartString
{ "az.Cy", "az-Cyrl" }, // # from old LocaleRefGetPartString
{ "az.La", "az" }, // # from old LocaleRefGetPartString
{ "be_??", "be_BY" }, // # from old MapScriptInfoAndISOCodes
{ "bn_??", "bn" }, // # from old LocaleRefGetPartString
{ "bo_??", "bo" }, // # from old MapScriptInfoAndISOCodes
{ "br_??", "br" }, // # from old MapScriptInfoAndISOCodes
{ "cy_??", "cy" }, // # from old MapScriptInfoAndISOCodes
{ "de-96", "de-1996" }, // # from old MapScriptInfoAndISOCodes // <1.9>
{ "de_96", "de-1996" }, // # from old MapScriptInfoAndISOCodes // <1.9>
{ "de_??", "de-1996" }, // # from old MapScriptInfoAndISOCodes
{ "el.El-P", "grc" }, // # from old LocaleRefGetPartString
{ "en-ascii", "en_001" }, // # from earlier version of tables in this file!
{ "en_??", "en_001" }, // # from old MapScriptInfoAndISOCodes
{ "eo_??", "eo" }, // # from old MapScriptInfoAndISOCodes
{ "es_??", "es_419" }, // # from old MapScriptInfoAndISOCodes
{ "es_XL", "es_419" }, // # from earlier version of tables in this file!
{ "fr_??", "fr_001" }, // # from old MapScriptInfoAndISOCodes
{ "ga-dots", "ga-Latg" }, // # from earlier version of tables in this file! // <1.8>
{ "ga-dots_IE", "ga-Latg_IE" }, // # from earlier version of tables in this file! // <1.8>
{ "ga.Lg", "ga-Latg" }, // # from old LocaleRefGetPartString // <1.8>
{ "ga.Lg_IE", "ga-Latg_IE" }, // # from old LocaleRefGetPartString // <1.8>
{ "gd_??", "gd" }, // # from old MapScriptInfoAndISOCodes
{ "gv_??", "gv" }, // # from old MapScriptInfoAndISOCodes
{ "jv.La", "jv" }, // # logical extension // <1.9>
{ "jw.La", "jv" }, // # from old LocaleRefGetPartString
{ "kk.Cy", "kk" }, // # from old LocaleRefGetPartString
{ "kl.La", "kl" }, // # from old LocaleRefGetPartString
{ "kl.La_GL", "kl_GL" }, // # from old LocaleRefGetPartString // <1.9>
{ "lp_??", "se" }, // # from old MapScriptInfoAndISOCodes
{ "mk_??", "mk_MK" }, // # from old MapScriptInfoAndISOCodes
{ "mn.Cy", "mn" }, // # from old LocaleRefGetPartString
{ "mn.Mn", "mn-Mong" }, // # from old LocaleRefGetPartString
{ "ms.Ar", "ms-Arab" }, // # from old LocaleRefGetPartString
{ "ms.La", "ms" }, // # from old LocaleRefGetPartString
{ "nl-be", "nl-BE" }, // # from old LocaleRefGetPartString
{ "nl-be_BE", "nl_BE" }, // # from old LocaleRefGetPartString
{ "no-NO", "nb-NO" }, // # not handled by localeStringPrefixToCanonical
{ "no-NO_NO", "nb-NO_NO" }, // # not handled by localeStringPrefixToCanonical
// { "no-bok_NO", "nb_NO" }, // # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
// { "no-nyn_NO", "nn_NO" }, // # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
// { "nya", "ny" }, // # from old LocaleRefGetPartString - handled by localeStringPrefixToCanonical
{ "pa_??", "pa" }, // # from old LocaleRefGetPartString
{ "sa.Dv", "sa" }, // # from old LocaleRefGetPartString
{ "sl_??", "sl_SI" }, // # from old MapScriptInfoAndISOCodes
{ "sr_??", "sr_RS" }, // # from old MapScriptInfoAndISOCodes // <1.18>
{ "su.La", "su" }, // # from old LocaleRefGetPartString
{ "yi.He", "yi" }, // # from old LocaleRefGetPartString
{ "zh-simp", "zh-Hans" }, // # from earlier version of tables in this file!
{ "zh-trad", "zh-Hant" }, // # from earlier version of tables in this file!
{ "zh.Ha-S", "zh-Hans" }, // # from old LocaleRefGetPartString
{ "zh.Ha-S_CN", "zh_CN" }, // # from old LocaleRefGetPartString
{ "zh.Ha-T", "zh-Hant" }, // # from old LocaleRefGetPartString
{ "zh.Ha-T_TW", "zh_TW" }, // # from old LocaleRefGetPartString
};
enum {
kNumOldAppleLocaleToCanonical = sizeof(oldAppleLocaleToCanonical)/sizeof(KeyStringToResultString)
};
static const KeyStringToResultString localeStringPrefixToCanonical[] = {
// Map 3-letter & obsolete ISO 639 codes, plus obsolete RFC 3066 codes, to 2-letter ISO 639 code.
// (special cases for 'sh' handled separately)
// First column must be all lowercase; must be sorted according to how strcmp compares the strings in the first column.
//
// non-canonical canonical [ comment ] # source/reason for non-canonical string
// prefix prefix
// ------------- ---------
{ "aar", "aa" }, // Afar
// { "aa_SAAHO", "ssy" }, // Saho # deprecated/grandfathered, handled as a special case
{ "abk", "ab" }, // Abkhazian
{ "afr", "af" }, // Afrikaans
{ "aju", "jrb" }, // Moroccan Judeo-Arabic -> Judeo-Arabic (macrolang.)
{ "aka", "ak" }, // Akan
{ "alb", "sq" }, // Albanian
{ "als", "sq" }, // Tosk Albanian -> Albanian (macrolang.)
{ "amh", "am" }, // Amharic
{ "ara", "ar" }, // Arabic
{ "arb", "ar" }, // Std Arabic -> Arabic (macrolang.)
{ "arg", "an" }, // Aragonese
{ "arm", "hy" }, // Armenian
{ "art-lojban", "jbo" }, // Lojban # deprecated/grandfathered
{ "asm", "as" }, // Assamese
{ "ava", "av" }, // Avaric
{ "ave", "ae" }, // Avestan
{ "aym", "ay" }, // Aymara
{ "ayr", "ay" }, // Central Aymara -> Aymara (macrolang.)
{ "aze", "az" }, // Azerbaijani
{ "azj", "az" }, // N.Azerbaijani -> Azerbaijani (macrolang.)
{ "bak", "ba" }, // Bashkir
{ "bam", "bm" }, // Bambara
{ "baq", "eu" }, // Basque
{ "bcc", "bal" }, // Balochi, Southern -> Baluchi (macrolang.)
{ "bcl", "bik" }, // Bicolano, Central -> Bikol (macrolang.)
{ "bel", "be" }, // Belarusian
{ "ben", "bn" }, // Bengali
{ "bih", "bh" }, // Bihari
{ "bis", "bi" }, // Bislama
{ "bod", "bo" }, // Tibetan
{ "bos", "bs" }, // Bosnian
{ "bre", "br" }, // Breton
{ "bul", "bg" }, // Bulgarian
{ "bur", "my" }, // Burmese
{ "bxk", "luy" }, // Lubukusu -> Luyia (macrolang.)
{ "bxr", "bua" }, // Buriat, Russia -> Buriat (macrolang.)
{ "cat", "ca" }, // Catalan
{ "ces", "cs" }, // Czech
{ "cha", "ch" }, // Chamorro
{ "che", "ce" }, // Chechen
{ "chi", "zh" }, // Chinese
{ "chu", "cu" }, // Church Slavic, Church Slavonic, Old Bulgarian, Old Church Slavonic, Old Slavonic
{ "chv", "cv" }, // Chuvash
{ "cld", "syr" }, // Chaldean Neo-Aramaic -> Syriac (macrolang.)
{ "cmn", "zh" }, // Mandarin -> Chinese (macrolang.)
{ "cor", "kw" }, // Cornish
{ "cos", "co" }, // Corsican
{ "cre", "cr" }, // Cree
{ "cwd", "cr" }, // Cree, Woods -> Cree (macrolang.)
{ "cym", "cy" }, // Welsh
{ "cze", "cs" }, // Czech
{ "dan", "da" }, // Danish
{ "deu", "de" }, // German
{ "dgo", "doi" }, // Dogri -> Dogri (macrolang.)
{ "dhd", "mwr" }, // Dhundari -> Marwari (macrolang.)
{ "dik", "din" }, // Southwestern Dinka -> Dinka (macrolang.)
{ "diq", "zza" }, // Dimli -> Zaza (macrolang.)
{ "div", "dv" }, // Dhivehi, Divehi, Maldivian
{ "dut", "nl" }, // Dutch
{ "dzo", "dz" }, // Dzongkha
{ "ekk", "et" }, // Std Estonian -> Estonian (macrolang.)
{ "ell", "el" }, // Greek, Modern (1453-)
{ "emk", "man" }, // Maninkakan, Eastern -> Mandingo (macrolang.)
{ "eng", "en" }, // English
{ "epo", "eo" }, // Esperanto
{ "esk", "ik" }, // Northwest Alaska Inupiatun -> Inupiaq (macrolang.)
{ "est", "et" }, // Estonian
{ "eus", "eu" }, // Basque
{ "ewe", "ee" }, // Ewe
{ "fao", "fo" }, // Faroese
{ "fas", "fa" }, // Persian
{ "fat", "ak" }, // Fanti -> Akan (macrolang.)
{ "fij", "fj" }, // Fijian
{ "fin", "fi" }, // Finnish
{ "fra", "fr" }, // French
{ "fre", "fr" }, // French
{ "fry", "fy" }, // Western Frisian
{ "fuc", "ff" }, // Pular -> Fulah (macrolang.)
{ "ful", "ff" }, // Fulah
{ "gaz", "om" }, // W.Central Oromo -> Oromo (macrolang.)
{ "gbo", "grb" }, // Northern Grebo -> Grebo (macrolang.)
{ "geo", "ka" }, // Georgian
{ "ger", "de" }, // German
{ "gla", "gd" }, // Gaelic,Scottish
{ "gle", "ga" }, // Irish
{ "glg", "gl" }, // Gallegan
{ "glv", "gv" }, // Manx
{ "gno", "gon" }, // Northern Gondi -> Gondi (macrolang.)
{ "gre", "el" }, // Greek, Modern (1453-)
{ "grn", "gn" }, // Guarani
{ "gug", "gn" }, // Paraguayan Guarani -> Guarani (macrolang.)
{ "guj", "gu" }, // Gujarati
{ "gya", "gba" }, // Northwest Gbaya -> Gbaya (Cent. Afr. Rep.) (macrolang.)
{ "hat", "ht" }, // Haitian, Haitian Creole
{ "hau", "ha" }, // Hausa
{ "hbs", "sr_Latn" }, // Serbo-Croatian
{ "hdn", "hai" }, // Northern Haida -> Haida (macrolang.)
{ "hea", "hmn" }, // Northern Qiandong Miao -> Hmong (macrolang.)
{ "heb", "he" }, // Hebrew
{ "her", "hz" }, // Herero
{ "him", "srx" }, // Himachali -> Sirmauri (= Pahari, Himachali) (macrolang.)
{ "hin", "hi" }, // Hindi
{ "hmo", "ho" }, // Hiri Motu
{ "hrv", "hr" }, // Croatian
{ "hun", "hu" }, // Hungarian
{ "hye", "hy" }, // Armenian
{ "i-ami", "ami" }, // Amis # deprecated/grandfathered
{ "i-bnn", "bnn" }, // Bunun # deprecated/grandfathered
{ "i-hak", "hak" }, // Hakka # deprecated RFC 3066
{ "i-klingon", "tlh" }, // Klingon # deprecated/grandfathered
{ "i-lux", "lb" }, // Luxembourgish # deprecated RFC 3066
{ "i-navajo", "nv" }, // Navajo # deprecated RFC 3066
{ "i-pwn", "pwn" }, // Paiwan # deprecated/grandfathered
{ "i-tao", "tao" }, // Tao # deprecated/grandfathered
{ "i-tay", "tay" }, // Tayal # deprecated/grandfathered
{ "i-tsu", "tsu" }, // Tsou # deprecated/grandfathered
{ "ibo", "ig" }, // Igbo
{ "ice", "is" }, // Icelandic
{ "ido", "io" }, // Ido
{ "iii", "ii" }, // Sichuan Yi, Nuosu
{ "ike", "iu" }, // E.Canada Inuktitut -> Inuktitut (macrolang.)
{ "iku", "iu" }, // Inuktitut
{ "ile", "ie" }, // Interlingue
{ "in", "id" }, // Indonesian # deprecated 639 code in -> id (1989)
{ "ina", "ia" }, // Interlingua
{ "ind", "id" }, // Indonesian
{ "ipk", "ik" }, // Inupiaq
{ "isl", "is" }, // Icelandic
{ "ita", "it" }, // Italian
{ "iw", "he" }, // Hebrew # deprecated 639 code iw -> he (1989)
{ "jav", "jv" }, // Javanese
{ "jaw", "jv" }, // Javanese # deprecated 639 code jaw -> jv (2001)
{ "ji", "yi" }, // Yiddish # deprecated 639 code ji -> yi (1989)
{ "jpn", "ja" }, // Japanese
{ "jw", "jv" }, // Javanese # deprecated
{ "kal", "kl" }, // Kalaallisut
{ "kan", "kn" }, // Kannada
{ "kas", "ks" }, // Kashmiri
{ "kat", "ka" }, // Georgian
{ "kau", "kr" }, // Kanuri
{ "kaz", "kk" }, // Kazakh
{ "khk", "mn" }, // Halh Mongolian [mainly Cyrl] -> Mongolian (macrolang.)
{ "khm", "km" }, // Khmer
{ "kik", "ki" }, // Kikuyu, Gikuyu
{ "kin", "rw" }, // Kinyarwanda
{ "kir", "ky" }, // Kirghiz
{ "kmr", "ku" }, // Northern Kurdish -> Kurdish (macrolang.)
{ "knc", "kr" }, // Central Kanuri -> Kanuri (macrolang.)
{ "kng", "kg" }, // Koongo -> Kongo (macrolang.)
{ "knn", "kok" }, // Konkani (individ.lang) -> Konkani (macrolang.)
{ "kom", "kv" }, // Komi
{ "kon", "kg" }, // Kongo
{ "kor", "ko" }, // Korean
{ "kpv", "kv" }, // Komi-Zyrian -> Komi (macrolang.)
{ "kua", "kj" }, // Kuanyama, Kwanyama
{ "kur", "ku" }, // Kurdish
{ "lao", "lo" }, // Lao
{ "lat", "la" }, // Latin
{ "lav", "lv" }, // Latvian
{ "lbk", "bnc" }, // Central Bontok -> Bontok (macrolang.)
{ "lim", "li" }, // Limburgan, Limburger, Limburgish
{ "lin", "ln" }, // Lingala
{ "lit", "lt" }, // Lithuanian
{ "ltz", "lb" }, // Letzeburgesch
{ "lub", "lu" }, // Luba-Katanga
{ "lug", "lg" }, // Ganda
{ "lvs", "lv" }, // Std Latvian -> Latvian (macrolang.)
{ "mac", "mk" }, // Macedonian
{ "mal", "ml" }, // Malayalam
{ "mar", "mr" }, // Marathi
{ "may", "ms" }, // Malay
{ "mhr", "chm" }, // Mari, Eastern -> Mari (Russia) (macrolang.)
{ "mkd", "mk" }, // Macedonian
{ "mlg", "mg" }, // Malagasy
{ "mlt", "mt" }, // Maltese
{ "mol", "mo" }, // Moldavian
{ "mon", "mn" }, // Mongolian
{ "msa", "ms" }, // Malay
{ "mup", "raj" }, // Malvi -> Rajasthani (macrolang.)
{ "mya", "my" }, // Burmese
{ "nau", "na" }, // Nauru
{ "nav", "nv" }, // Navajo, Navaho
{ "nbl", "nr" }, // South Ndebele
{ "nde", "nd" }, // North Ndebele
{ "ndo", "ng" }, // Ndonga
{ "nep", "ne" }, // Nepali
{ "nld", "nl" }, // Dutch
{ "nno", "nn" }, // Norwegian Nynorsk
{ "no", "nb" }, // Norwegian generic # ambiguous 639 code no -> nb
{ "no-bok", "nb" }, // Norwegian Bokmal # deprecated RFC 3066 tag - used in old LocaleRefGetPartString
{ "no-nyn", "nn" }, // Norwegian Nynorsk # deprecated RFC 3066 tag - used in old LocaleRefGetPartString
{ "nob", "nb" }, // Norwegian Bokmal
{ "nor", "nb" }, // Norwegian generic # ambiguous 639 code nor -> nb
// { "no_BOKMAL", "nb" }, // Norwegian Bokmal # deprecated/grandfathered, handled as a special case
// { "no_NYNORSK", "nn" }, // Norwegian Nynorsk # deprecated/grandfathered, handled as a special case
{ "nya", "ny" }, // Nyanja/Chewa/Chichewa # 3-letter code used in old LocaleRefGetPartString
{ "oci", "oc" }, // Occitan/Provencal
{ "ojg", "oj" }, // Ojibwa, Eastern -> Ojibwa (macrolang.)
{ "oji", "oj" }, // Ojibwa
{ "ori", "or" }, // Oriya
{ "orm", "om" }, // Oromo,Galla
{ "oss", "os" }, // Ossetian, Ossetic
{ "pan", "pa" }, // Panjabi
{ "pbu", "ps" }, // N.Pashto, -> Pushto (macrolang.)
{ "per", "fa" }, // Persian
{ "pes", "fa" }, // W.Farsi -> Persian (macrolang.)
{ "pli", "pi" }, // Pali
{ "plt", "mg" }, // Plateau Malagasy -> Malagasy (macrolang.)
{ "pnb", "lah" }, // W.Panjabi -> Lahnda (macrolang.)
{ "pol", "pl" }, // Polish
{ "por", "pt" }, // Portuguese
{ "pus", "ps" }, // Pushto
{ "que", "qu" }, // Quechua
{ "qxp", "qu" }, // Puno Quechua -> Quechua (macrolang.)
{ "rmy", "rom" }, // Vlax Romani -> Romany (macrolang.)
{ "roh", "rm" }, // Raeto-Romance
{ "ron", "ro" }, // Romanian
{ "rum", "ro" }, // Romanian
{ "run", "rn" }, // Rundi
{ "rus", "ru" }, // Russian
{ "sag", "sg" }, // Sango
{ "san", "sa" }, // Sanskrit
{ "scc", "sr" }, // Serbian
{ "scr", "hr" }, // Croatian
{ "sgn-be-fr", "sfb" }, // Belgian-French Sign Lang. # deprecated/grandfathered
{ "sgn-be-nl", "vgt" }, // Belgian-Flemish Sign Lang. # deprecated/grandfathered
{ "sgn-ch-de", "sgg" }, // Swiss German Sign Lang. # deprecated/grandfathered
{ "sin", "si" }, // Sinhalese
{ "slk", "sk" }, // Slovak
{ "slo", "sk" }, // Slovak
{ "slv", "sl" }, // Slovenian
{ "sme", "se" }, // Sami,Northern
{ "smo", "sm" }, // Samoan
{ "sna", "sn" }, // Shona
{ "snd", "sd" }, // Sindhi
{ "som", "so" }, // Somali
{ "sot", "st" }, // Southern Sotho
{ "spa", "es" }, // Spanish
{ "spy", "kln" }, // Sabaot -> Kalenjin (macrolang.)
{ "sqi", "sq" }, // Albanian
{ "src", "sc" }, // Sardinian, Logudorese -> Sardinian (macrolang.)
{ "srd", "sc" }, // Sardinian
{ "srp", "sr" }, // Serbian
{ "ssw", "ss" }, // Swati
{ "sun", "su" }, // Sundanese
{ "swa", "sw" }, // Swahili
{ "swe", "sv" }, // Swedish
{ "swh", "sw" }, // Swahili (individ.lang) -> Swahili (macrolang.)
{ "tah", "ty" }, // Tahitian
{ "tam", "ta" }, // Tamil
{ "tat", "tt" }, // Tatar
{ "tel", "te" }, // Telugu
{ "tgk", "tg" }, // Tajik
{ "tgl", "fil" }, // Tagalog
{ "tha", "th" }, // Thai
{ "tib", "bo" }, // Tibetan
{ "tir", "ti" }, // Tigrinya
{ "tl", "fil" }, // Tagalog # legacy
{ "ton", "to" }, // Tongan
{ "tsn", "tn" }, // Tswana
{ "tso", "ts" }, // Tsonga
{ "ttq", "tmh" }, // Tamajaq, Tawallammat -> Tamashek (macrolang.)
{ "tuk", "tk" }, // Turkmen
{ "tur", "tr" }, // Turkish
{ "tw", "ak" }, // Twi -> Akan (macrolang.)
{ "twi", "ak" }, // Twi
{ "uig", "ug" }, // Uighur
{ "ukr", "uk" }, // Ukrainian
{ "umu", "del" }, // Munsee -> Delaware (macrolang.)
{ "urd", "ur" }, // Urdu
{ "uzb", "uz" }, // Uzbek
{ "uzn", "uz" }, // N. Uzbek -> Uzbek (macrolang.)
{ "ven", "ve" }, // Venda
{ "vie", "vi" }, // Vietnamese
{ "vol", "vo" }, // Volapük
{ "wel", "cy" }, // Welsh
{ "wln", "wa" }, // Walloon
{ "wol", "wo" }, // Wolof
{ "xho", "xh" }, // Xhosa
{ "xpe", "kpe" }, // Kpelle, Liberia -> Kpelle (macrolang.)
{ "xsl", "den" }, // Slavey, South -> Slave (Athapascan) (macrolang.)
{ "ydd", "yi" }, // Yiddish,E. -> Yiddish (macrolang.)
{ "yid", "yi" }, // Yiddish
{ "yor", "yo" }, // Yoruba
{ "zai", "zap" }, // Zapotec, Isthmus -> Zapotec (macrolang.)
{ "zh-cdo", "cdo" }, // Chinese, Min Dong # extlang
{ "zh-cjy", "cjy" }, // Chinese, Jinyu # extlang
{ "zh-cmn", "zh" }, // Chinese, Mandarin # extlang
{ "zh-cpx", "cpx" }, // Chinese, Pu-Xian # extlang
{ "zh-czh", "czh" }, // Chinese, Huizhou # extlang
{ "zh-czo", "czo" }, // Chinese, Min Zhong # extlang
{ "zh-gan", "gan" }, // Chinese, Gan # extlang
{ "zh-guoyu", "zh" }, // Mandarin/Std Chinese # deprecated
{ "zh-hak", "hak" }, // Chinese, Hakka # extlang
{ "zh-hakka", "hak" }, // Hakka # deprecated
{ "zh-hsn", "hsn" }, // Chinese, Xiang # extlang
{ "zh-min-nan", "nan" }, // Minnan,Hokkien,Taiwanese,So. Fujian # deprecated
{ "zh-mnp", "mnp" }, // Chinese, Min Bei # extlang
{ "zh-nan", "nan" }, // Chinese, Min Nan # extlang
{ "zh-wuu", "wuu" }, // Chinese, Wu # extlang
{ "zh-xiang", "hsn" }, // Xiang/Hunanese # deprecated
{ "zh-yue", "yue" }, // Chinese, Yue # extlang
{ "zha", "za" }, // Zhuang, Chuang
{ "zho", "zh" }, // Chinese
{ "zsm", "ms" }, // Std Malay -> Malay (macrolang.)
{ "zul", "zu" }, // Zulu
{ "zyb", "za" }, // Yongbei Zhuang -> Zhuang (macrolang.)
};
enum {
kNumLocaleStringPrefixToCanonical = sizeof(localeStringPrefixToCanonical)/sizeof(KeyStringToResultString)
};
static const SpecialCaseUpdates specialCases[] = {
// Data for special cases
// a) The 3166 code CS was used for Czechoslovakia until 1993, when that country split and the code was
// replaced by CZ and SK. Then in 2003-07, the code YU (formerly designating all of Yugoslavia, then after
// the 1990s breakup just designating what is now Serbia and Montenegro) was changed to CS! Then after
// Serbia and Montenegro split, the code CS was replaced in 2006-09 with separate codes RS and ME. If we
// see CS but a language of cs or sk, we change CS to CZ or SK. Otherwise, we change CS (and old YU) to RS.
// b) The 639 code sh for Serbo-Croatian was also replaced in the 1990s by separate codes hr and sr, and
// deprecated in 2000. We guess which one to map it to as follows: If there is a region tag of HR we use
// hr; if there is a region tag of (now) RS we use sr; else we do not change it (not enough info).
// c) There are other codes that have been updated without these issues (eg. TP to TL), plus among the
// "exceptionally reserved" codes some are just alternates for standard codes (eg. UK for GB).
{ NULL, "-UK", "GB", NULL, NULL }, // always change UK to GB (UK is "exceptionally reserved" to mean GB)
{ NULL, "-TP", "TL", NULL, NULL }, // always change TP to TL (East Timor, code changed 2002-05)
{ "cs", "-CS", "CZ", NULL, NULL }, // if language is cs, change CS (pre-1993 Czechoslovakia) to CZ (Czech Republic)
{ "sk", "-CS", "SK", NULL, NULL }, // if language is sk, change CS (pre-1993 Czechoslovakia) to SK (Slovakia)
{ NULL, "-CS", "RS", NULL, NULL }, // otherwise map CS (assume Serbia+Montenegro) to RS (Serbia)
{ NULL, "-YU", "RS", NULL, NULL }, // also map old YU (assume Serbia+Montenegro) to RS (Serbia)
{ "sh", "-HR", "hr", "-RS", "sr" }, // then if language is old 'sh' (SerboCroatian), change it to 'hr' (Croatian)
// if we find HR (Croatia) or to 'sr' (Serbian) if we find RS (Serbia).
// Note: Do this after changing YU/CS toRS as above.
{ NULL, NULL, NULL, NULL, NULL } // terminator
};
static const KeyStringToResultString localeStringRegionToDefaults[] = {
// For some region-code suffixes, there are default substrings to strip off for canonical string.
// Must be sorted according to how strcmp compares the strings in the first column
//
// region default writing
// suffix system tags, strip comment
// -------- ------------- ---------
{ "_CN", "-Hans" }, // mainland China, default is simplified
{ "_HK", "-Hant" }, // Hong Kong, default is traditional
{ "_MO", "-Hant" }, // Macao, default is traditional
{ "_SG", "-Hans" }, // Singapore, default is simplified
{ "_TW", "-Hant" }, // Taiwan, default is traditional
};
enum {
kNumLocaleStringRegionToDefaults = sizeof(localeStringRegionToDefaults)/sizeof(KeyStringToResultString)
};
static const KeyStringToResultString localeStringPrefixToDefaults[] = {
// For some initial portions of language tag, there are default substrings to strip off for canonical string.
// Must be sorted according to how strcmp compares the strings in the first column
//
// language default writing
// tag prefix system tags, strip comment
// -------- ------------- ---------
{ "ab-", "-Cyrl" }, // Abkhazian
{ "af-", "-Latn" }, // Afrikaans
{ "agq-", "-Latn" }, // Aghem
{ "ak-", "-Latn" }, // Akan
{ "am-", "-Ethi" }, // Amharic
{ "ar-", "-Arab" }, // Arabic
{ "as-", "-Beng" }, // Assamese
{ "asa-", "-Latn" }, // Asu
{ "ay-", "-Latn" }, // Aymara
{ "az-", "-Latn" }, // Azerbaijani
{ "bas-", "-Latn" }, // Basaa
{ "be-", "-Cyrl" }, // Belarusian
{ "bem-", "-Latn" }, // Bemba
{ "bez-", "-Latn" }, // Bena
{ "bg-", "-Cyrl" }, // Bulgarian
{ "bm-", "-Latn" }, // Bambara
{ "bn-", "-Beng" }, // Bengali
{ "bo-", "-Tibt" }, // Tibetan (? not Suppress-Script)
{ "br-", "-Latn" }, // Breton (? not Suppress-Script)
{ "brx-", "-Deva" }, // Bodo
{ "bs-", "-Latn" }, // Bosnian
{ "ca-", "-Latn" }, // Catalan
{ "cgg-", "-Latn" }, // Chiga
{ "chr-", "-Cher" }, // Cherokee
{ "cs-", "-Latn" }, // Czech
{ "cy-", "-Latn" }, // Welsh
{ "da-", "-Latn" }, // Danish
{ "dav-", "-Latn" }, // Taita
{ "de-", "-Latn -1901" }, // German, traditional orthography
{ "dje-", "-Latn" }, // Zarma
{ "dua-", "-Latn" }, // Duala
{ "dv-", "-Thaa" }, // Divehi/Maldivian
{ "dyo-", "-Latn" }, // Jola-Fonyi
{ "dz-", "-Tibt" }, // Dzongkha
{ "ebu-", "-Latn" }, // Embu
{ "ee-", "-Latn" }, // Ewe
{ "el-", "-Grek" }, // Greek (modern, monotonic)
{ "en-", "-Latn" }, // English
{ "eo-", "-Latn" }, // Esperanto
{ "es-", "-Latn" }, // Spanish
{ "et-", "-Latn" }, // Estonian
{ "eu-", "-Latn" }, // Basque
{ "ewo-", "-Latn" }, // Ewondo
{ "fa-", "-Arab" }, // Farsi
{ "ff-", "-Latn" }, // Fulah
{ "fi-", "-Latn" }, // Finnish
{ "fil-", "-Latn" }, // Tagalog
{ "fo-", "-Latn" }, // Faroese
{ "fr-", "-Latn" }, // French
{ "ga-", "-Latn" }, // Irish
{ "gd-", "-Latn" }, // Scottish Gaelic (? not Suppress-Script)
{ "gl-", "-Latn" }, // Galician
{ "gn-", "-Latn" }, // Guarani
{ "gsw-", "-Latn" }, // Swiss German
{ "gu-", "-Gujr" }, // Gujarati
{ "guz-", "-Latn" }, // Gusii
{ "gv-", "-Latn" }, // Manx
{ "ha-", "-Latn" }, // Hausa
{ "haw-", "-Latn" }, // Hawaiian (? not Suppress-Script)
{ "he-", "-Hebr" }, // Hebrew
{ "hi-", "-Deva" }, // Hindi
{ "hr-", "-Latn" }, // Croatian
{ "hu-", "-Latn" }, // Hungarian
{ "hy-", "-Armn" }, // Armenian
{ "id-", "-Latn" }, // Indonesian
{ "ig-", "-Latn" }, // Igbo
{ "ii-", "-Yiii" }, // Sichuan Yi