fstat: Fix module dependency conditions.
[gnulib/ericb.git] / lib / localename.c
blob3ba9d08664a7ddc42cdb7d05a7216a454910d347
1 /* Determine name of the currently selected locale.
2 Copyright (C) 1995-2017 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
18 /* Native Windows code written by Tor Lillqvist <tml@iki.fi>. */
19 /* Mac OS X code written by Bruno Haible <bruno@clisp.org>. */
21 #include <config.h>
23 /* Specification. */
24 #ifdef IN_LIBINTL
25 # include "gettextP.h"
26 #else
27 # include "localename.h"
28 #endif
30 #include <limits.h>
31 #include <stddef.h>
32 #include <stdlib.h>
33 #include <locale.h>
34 #include <string.h>
36 #include "flexmember.h"
38 #if HAVE_USELOCALE
39 /* Mac OS X 10.5 defines the locale_t type in <xlocale.h>. */
40 # if defined __APPLE__ && defined __MACH__
41 # include <xlocale.h>
42 # endif
43 # if __GLIBC__ >= 2 && !defined __UCLIBC__
44 # include <langinfo.h>
45 # endif
46 # if !defined IN_LIBINTL
47 # include "glthread/lock.h"
48 # endif
49 # if defined __sun && HAVE_GETLOCALENAME_L
50 /* Solaris >= 12. */
51 extern char * getlocalename_l(int, locale_t);
52 # endif
53 #endif
55 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
56 # include <CoreFoundation/CFString.h>
57 # if HAVE_CFLOCALECOPYCURRENT
58 # include <CoreFoundation/CFLocale.h>
59 # elif HAVE_CFPREFERENCESCOPYAPPVALUE
60 # include <CoreFoundation/CFPreferences.h>
61 # endif
62 #endif
64 #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__
65 # define WINDOWS_NATIVE
66 # if !defined IN_LIBINTL
67 # include "glthread/lock.h"
68 # endif
69 #endif
71 #if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
72 # define WIN32_LEAN_AND_MEAN
73 # include <windows.h>
74 # include <winnls.h>
75 /* List of language codes, sorted by value:
76 0x01 LANG_ARABIC
77 0x02 LANG_BULGARIAN
78 0x03 LANG_CATALAN
79 0x04 LANG_CHINESE
80 0x05 LANG_CZECH
81 0x06 LANG_DANISH
82 0x07 LANG_GERMAN
83 0x08 LANG_GREEK
84 0x09 LANG_ENGLISH
85 0x0a LANG_SPANISH
86 0x0b LANG_FINNISH
87 0x0c LANG_FRENCH
88 0x0d LANG_HEBREW
89 0x0e LANG_HUNGARIAN
90 0x0f LANG_ICELANDIC
91 0x10 LANG_ITALIAN
92 0x11 LANG_JAPANESE
93 0x12 LANG_KOREAN
94 0x13 LANG_DUTCH
95 0x14 LANG_NORWEGIAN
96 0x15 LANG_POLISH
97 0x16 LANG_PORTUGUESE
98 0x17 LANG_ROMANSH
99 0x18 LANG_ROMANIAN
100 0x19 LANG_RUSSIAN
101 0x1a LANG_CROATIAN == LANG_SERBIAN
102 0x1b LANG_SLOVAK
103 0x1c LANG_ALBANIAN
104 0x1d LANG_SWEDISH
105 0x1e LANG_THAI
106 0x1f LANG_TURKISH
107 0x20 LANG_URDU
108 0x21 LANG_INDONESIAN
109 0x22 LANG_UKRAINIAN
110 0x23 LANG_BELARUSIAN
111 0x24 LANG_SLOVENIAN
112 0x25 LANG_ESTONIAN
113 0x26 LANG_LATVIAN
114 0x27 LANG_LITHUANIAN
115 0x28 LANG_TAJIK
116 0x29 LANG_FARSI
117 0x2a LANG_VIETNAMESE
118 0x2b LANG_ARMENIAN
119 0x2c LANG_AZERI
120 0x2d LANG_BASQUE
121 0x2e LANG_SORBIAN
122 0x2f LANG_MACEDONIAN
123 0x30 LANG_SUTU
124 0x31 LANG_TSONGA
125 0x32 LANG_TSWANA
126 0x33 LANG_VENDA
127 0x34 LANG_XHOSA
128 0x35 LANG_ZULU
129 0x36 LANG_AFRIKAANS
130 0x37 LANG_GEORGIAN
131 0x38 LANG_FAEROESE
132 0x39 LANG_HINDI
133 0x3a LANG_MALTESE
134 0x3b LANG_SAMI
135 0x3c LANG_GAELIC
136 0x3d LANG_YIDDISH
137 0x3e LANG_MALAY
138 0x3f LANG_KAZAK
139 0x40 LANG_KYRGYZ
140 0x41 LANG_SWAHILI
141 0x42 LANG_TURKMEN
142 0x43 LANG_UZBEK
143 0x44 LANG_TATAR
144 0x45 LANG_BENGALI
145 0x46 LANG_PUNJABI
146 0x47 LANG_GUJARATI
147 0x48 LANG_ORIYA
148 0x49 LANG_TAMIL
149 0x4a LANG_TELUGU
150 0x4b LANG_KANNADA
151 0x4c LANG_MALAYALAM
152 0x4d LANG_ASSAMESE
153 0x4e LANG_MARATHI
154 0x4f LANG_SANSKRIT
155 0x50 LANG_MONGOLIAN
156 0x51 LANG_TIBETAN
157 0x52 LANG_WELSH
158 0x53 LANG_CAMBODIAN
159 0x54 LANG_LAO
160 0x55 LANG_BURMESE
161 0x56 LANG_GALICIAN
162 0x57 LANG_KONKANI
163 0x58 LANG_MANIPURI
164 0x59 LANG_SINDHI
165 0x5a LANG_SYRIAC
166 0x5b LANG_SINHALESE
167 0x5c LANG_CHEROKEE
168 0x5d LANG_INUKTITUT
169 0x5e LANG_AMHARIC
170 0x5f LANG_TAMAZIGHT
171 0x60 LANG_KASHMIRI
172 0x61 LANG_NEPALI
173 0x62 LANG_FRISIAN
174 0x63 LANG_PASHTO
175 0x64 LANG_TAGALOG
176 0x65 LANG_DIVEHI
177 0x66 LANG_EDO
178 0x67 LANG_FULFULDE
179 0x68 LANG_HAUSA
180 0x69 LANG_IBIBIO
181 0x6a LANG_YORUBA
182 0x6d LANG_BASHKIR
183 0x6e LANG_LUXEMBOURGISH
184 0x6f LANG_GREENLANDIC
185 0x70 LANG_IGBO
186 0x71 LANG_KANURI
187 0x72 LANG_OROMO
188 0x73 LANG_TIGRINYA
189 0x74 LANG_GUARANI
190 0x75 LANG_HAWAIIAN
191 0x76 LANG_LATIN
192 0x77 LANG_SOMALI
193 0x78 LANG_YI
194 0x79 LANG_PAPIAMENTU
195 0x7a LANG_MAPUDUNGUN
196 0x7c LANG_MOHAWK
197 0x7e LANG_BRETON
198 0x82 LANG_OCCITAN
199 0x83 LANG_CORSICAN
200 0x84 LANG_ALSATIAN
201 0x85 LANG_YAKUT
202 0x86 LANG_KICHE
203 0x87 LANG_KINYARWANDA
204 0x88 LANG_WOLOF
205 0x8c LANG_DARI
206 0x91 LANG_SCOTTISH_GAELIC
208 /* Mingw headers don't have latest language and sublanguage codes. */
209 # ifndef LANG_AFRIKAANS
210 # define LANG_AFRIKAANS 0x36
211 # endif
212 # ifndef LANG_ALBANIAN
213 # define LANG_ALBANIAN 0x1c
214 # endif
215 # ifndef LANG_ALSATIAN
216 # define LANG_ALSATIAN 0x84
217 # endif
218 # ifndef LANG_AMHARIC
219 # define LANG_AMHARIC 0x5e
220 # endif
221 # ifndef LANG_ARABIC
222 # define LANG_ARABIC 0x01
223 # endif
224 # ifndef LANG_ARMENIAN
225 # define LANG_ARMENIAN 0x2b
226 # endif
227 # ifndef LANG_ASSAMESE
228 # define LANG_ASSAMESE 0x4d
229 # endif
230 # ifndef LANG_AZERI
231 # define LANG_AZERI 0x2c
232 # endif
233 # ifndef LANG_BASHKIR
234 # define LANG_BASHKIR 0x6d
235 # endif
236 # ifndef LANG_BASQUE
237 # define LANG_BASQUE 0x2d
238 # endif
239 # ifndef LANG_BELARUSIAN
240 # define LANG_BELARUSIAN 0x23
241 # endif
242 # ifndef LANG_BENGALI
243 # define LANG_BENGALI 0x45
244 # endif
245 # ifndef LANG_BRETON
246 # define LANG_BRETON 0x7e
247 # endif
248 # ifndef LANG_BURMESE
249 # define LANG_BURMESE 0x55
250 # endif
251 # ifndef LANG_CAMBODIAN
252 # define LANG_CAMBODIAN 0x53
253 # endif
254 # ifndef LANG_CATALAN
255 # define LANG_CATALAN 0x03
256 # endif
257 # ifndef LANG_CHEROKEE
258 # define LANG_CHEROKEE 0x5c
259 # endif
260 # ifndef LANG_CORSICAN
261 # define LANG_CORSICAN 0x83
262 # endif
263 # ifndef LANG_DARI
264 # define LANG_DARI 0x8c
265 # endif
266 # ifndef LANG_DIVEHI
267 # define LANG_DIVEHI 0x65
268 # endif
269 # ifndef LANG_EDO
270 # define LANG_EDO 0x66
271 # endif
272 # ifndef LANG_ESTONIAN
273 # define LANG_ESTONIAN 0x25
274 # endif
275 # ifndef LANG_FAEROESE
276 # define LANG_FAEROESE 0x38
277 # endif
278 # ifndef LANG_FARSI
279 # define LANG_FARSI 0x29
280 # endif
281 # ifndef LANG_FRISIAN
282 # define LANG_FRISIAN 0x62
283 # endif
284 # ifndef LANG_FULFULDE
285 # define LANG_FULFULDE 0x67
286 # endif
287 # ifndef LANG_GAELIC
288 # define LANG_GAELIC 0x3c
289 # endif
290 # ifndef LANG_GALICIAN
291 # define LANG_GALICIAN 0x56
292 # endif
293 # ifndef LANG_GEORGIAN
294 # define LANG_GEORGIAN 0x37
295 # endif
296 # ifndef LANG_GREENLANDIC
297 # define LANG_GREENLANDIC 0x6f
298 # endif
299 # ifndef LANG_GUARANI
300 # define LANG_GUARANI 0x74
301 # endif
302 # ifndef LANG_GUJARATI
303 # define LANG_GUJARATI 0x47
304 # endif
305 # ifndef LANG_HAUSA
306 # define LANG_HAUSA 0x68
307 # endif
308 # ifndef LANG_HAWAIIAN
309 # define LANG_HAWAIIAN 0x75
310 # endif
311 # ifndef LANG_HEBREW
312 # define LANG_HEBREW 0x0d
313 # endif
314 # ifndef LANG_HINDI
315 # define LANG_HINDI 0x39
316 # endif
317 # ifndef LANG_IBIBIO
318 # define LANG_IBIBIO 0x69
319 # endif
320 # ifndef LANG_IGBO
321 # define LANG_IGBO 0x70
322 # endif
323 # ifndef LANG_INDONESIAN
324 # define LANG_INDONESIAN 0x21
325 # endif
326 # ifndef LANG_INUKTITUT
327 # define LANG_INUKTITUT 0x5d
328 # endif
329 # ifndef LANG_KANNADA
330 # define LANG_KANNADA 0x4b
331 # endif
332 # ifndef LANG_KANURI
333 # define LANG_KANURI 0x71
334 # endif
335 # ifndef LANG_KASHMIRI
336 # define LANG_KASHMIRI 0x60
337 # endif
338 # ifndef LANG_KAZAK
339 # define LANG_KAZAK 0x3f
340 # endif
341 # ifndef LANG_KICHE
342 # define LANG_KICHE 0x86
343 # endif
344 # ifndef LANG_KINYARWANDA
345 # define LANG_KINYARWANDA 0x87
346 # endif
347 # ifndef LANG_KONKANI
348 # define LANG_KONKANI 0x57
349 # endif
350 # ifndef LANG_KYRGYZ
351 # define LANG_KYRGYZ 0x40
352 # endif
353 # ifndef LANG_LAO
354 # define LANG_LAO 0x54
355 # endif
356 # ifndef LANG_LATIN
357 # define LANG_LATIN 0x76
358 # endif
359 # ifndef LANG_LATVIAN
360 # define LANG_LATVIAN 0x26
361 # endif
362 # ifndef LANG_LITHUANIAN
363 # define LANG_LITHUANIAN 0x27
364 # endif
365 # ifndef LANG_LUXEMBOURGISH
366 # define LANG_LUXEMBOURGISH 0x6e
367 # endif
368 # ifndef LANG_MACEDONIAN
369 # define LANG_MACEDONIAN 0x2f
370 # endif
371 # ifndef LANG_MALAY
372 # define LANG_MALAY 0x3e
373 # endif
374 # ifndef LANG_MALAYALAM
375 # define LANG_MALAYALAM 0x4c
376 # endif
377 # ifndef LANG_MALTESE
378 # define LANG_MALTESE 0x3a
379 # endif
380 # ifndef LANG_MANIPURI
381 # define LANG_MANIPURI 0x58
382 # endif
383 # ifndef LANG_MAORI
384 # define LANG_MAORI 0x81
385 # endif
386 # ifndef LANG_MAPUDUNGUN
387 # define LANG_MAPUDUNGUN 0x7a
388 # endif
389 # ifndef LANG_MARATHI
390 # define LANG_MARATHI 0x4e
391 # endif
392 # ifndef LANG_MOHAWK
393 # define LANG_MOHAWK 0x7c
394 # endif
395 # ifndef LANG_MONGOLIAN
396 # define LANG_MONGOLIAN 0x50
397 # endif
398 # ifndef LANG_NEPALI
399 # define LANG_NEPALI 0x61
400 # endif
401 # ifndef LANG_OCCITAN
402 # define LANG_OCCITAN 0x82
403 # endif
404 # ifndef LANG_ORIYA
405 # define LANG_ORIYA 0x48
406 # endif
407 # ifndef LANG_OROMO
408 # define LANG_OROMO 0x72
409 # endif
410 # ifndef LANG_PAPIAMENTU
411 # define LANG_PAPIAMENTU 0x79
412 # endif
413 # ifndef LANG_PASHTO
414 # define LANG_PASHTO 0x63
415 # endif
416 # ifndef LANG_PUNJABI
417 # define LANG_PUNJABI 0x46
418 # endif
419 # ifndef LANG_QUECHUA
420 # define LANG_QUECHUA 0x6b
421 # endif
422 # ifndef LANG_ROMANSH
423 # define LANG_ROMANSH 0x17
424 # endif
425 # ifndef LANG_SAMI
426 # define LANG_SAMI 0x3b
427 # endif
428 # ifndef LANG_SANSKRIT
429 # define LANG_SANSKRIT 0x4f
430 # endif
431 # ifndef LANG_SCOTTISH_GAELIC
432 # define LANG_SCOTTISH_GAELIC 0x91
433 # endif
434 # ifndef LANG_SERBIAN
435 # define LANG_SERBIAN 0x1a
436 # endif
437 # ifndef LANG_SINDHI
438 # define LANG_SINDHI 0x59
439 # endif
440 # ifndef LANG_SINHALESE
441 # define LANG_SINHALESE 0x5b
442 # endif
443 # ifndef LANG_SLOVAK
444 # define LANG_SLOVAK 0x1b
445 # endif
446 # ifndef LANG_SOMALI
447 # define LANG_SOMALI 0x77
448 # endif
449 # ifndef LANG_SORBIAN
450 # define LANG_SORBIAN 0x2e
451 # endif
452 # ifndef LANG_SOTHO
453 # define LANG_SOTHO 0x6c
454 # endif
455 # ifndef LANG_SUTU
456 # define LANG_SUTU 0x30
457 # endif
458 # ifndef LANG_SWAHILI
459 # define LANG_SWAHILI 0x41
460 # endif
461 # ifndef LANG_SYRIAC
462 # define LANG_SYRIAC 0x5a
463 # endif
464 # ifndef LANG_TAGALOG
465 # define LANG_TAGALOG 0x64
466 # endif
467 # ifndef LANG_TAJIK
468 # define LANG_TAJIK 0x28
469 # endif
470 # ifndef LANG_TAMAZIGHT
471 # define LANG_TAMAZIGHT 0x5f
472 # endif
473 # ifndef LANG_TAMIL
474 # define LANG_TAMIL 0x49
475 # endif
476 # ifndef LANG_TATAR
477 # define LANG_TATAR 0x44
478 # endif
479 # ifndef LANG_TELUGU
480 # define LANG_TELUGU 0x4a
481 # endif
482 # ifndef LANG_THAI
483 # define LANG_THAI 0x1e
484 # endif
485 # ifndef LANG_TIBETAN
486 # define LANG_TIBETAN 0x51
487 # endif
488 # ifndef LANG_TIGRINYA
489 # define LANG_TIGRINYA 0x73
490 # endif
491 # ifndef LANG_TSONGA
492 # define LANG_TSONGA 0x31
493 # endif
494 # ifndef LANG_TSWANA
495 # define LANG_TSWANA 0x32
496 # endif
497 # ifndef LANG_TURKMEN
498 # define LANG_TURKMEN 0x42
499 # endif
500 # ifndef LANG_UIGHUR
501 # define LANG_UIGHUR 0x80
502 # endif
503 # ifndef LANG_UKRAINIAN
504 # define LANG_UKRAINIAN 0x22
505 # endif
506 # ifndef LANG_URDU
507 # define LANG_URDU 0x20
508 # endif
509 # ifndef LANG_UZBEK
510 # define LANG_UZBEK 0x43
511 # endif
512 # ifndef LANG_VENDA
513 # define LANG_VENDA 0x33
514 # endif
515 # ifndef LANG_VIETNAMESE
516 # define LANG_VIETNAMESE 0x2a
517 # endif
518 # ifndef LANG_WELSH
519 # define LANG_WELSH 0x52
520 # endif
521 # ifndef LANG_WOLOF
522 # define LANG_WOLOF 0x88
523 # endif
524 # ifndef LANG_XHOSA
525 # define LANG_XHOSA 0x34
526 # endif
527 # ifndef LANG_YAKUT
528 # define LANG_YAKUT 0x85
529 # endif
530 # ifndef LANG_YI
531 # define LANG_YI 0x78
532 # endif
533 # ifndef LANG_YIDDISH
534 # define LANG_YIDDISH 0x3d
535 # endif
536 # ifndef LANG_YORUBA
537 # define LANG_YORUBA 0x6a
538 # endif
539 # ifndef LANG_ZULU
540 # define LANG_ZULU 0x35
541 # endif
542 # ifndef SUBLANG_AFRIKAANS_SOUTH_AFRICA
543 # define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
544 # endif
545 # ifndef SUBLANG_ALBANIAN_ALBANIA
546 # define SUBLANG_ALBANIAN_ALBANIA 0x01
547 # endif
548 # ifndef SUBLANG_ALSATIAN_FRANCE
549 # define SUBLANG_ALSATIAN_FRANCE 0x01
550 # endif
551 # ifndef SUBLANG_AMHARIC_ETHIOPIA
552 # define SUBLANG_AMHARIC_ETHIOPIA 0x01
553 # endif
554 # ifndef SUBLANG_ARABIC_SAUDI_ARABIA
555 # define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
556 # endif
557 # ifndef SUBLANG_ARABIC_IRAQ
558 # define SUBLANG_ARABIC_IRAQ 0x02
559 # endif
560 # ifndef SUBLANG_ARABIC_EGYPT
561 # define SUBLANG_ARABIC_EGYPT 0x03
562 # endif
563 # ifndef SUBLANG_ARABIC_LIBYA
564 # define SUBLANG_ARABIC_LIBYA 0x04
565 # endif
566 # ifndef SUBLANG_ARABIC_ALGERIA
567 # define SUBLANG_ARABIC_ALGERIA 0x05
568 # endif
569 # ifndef SUBLANG_ARABIC_MOROCCO
570 # define SUBLANG_ARABIC_MOROCCO 0x06
571 # endif
572 # ifndef SUBLANG_ARABIC_TUNISIA
573 # define SUBLANG_ARABIC_TUNISIA 0x07
574 # endif
575 # ifndef SUBLANG_ARABIC_OMAN
576 # define SUBLANG_ARABIC_OMAN 0x08
577 # endif
578 # ifndef SUBLANG_ARABIC_YEMEN
579 # define SUBLANG_ARABIC_YEMEN 0x09
580 # endif
581 # ifndef SUBLANG_ARABIC_SYRIA
582 # define SUBLANG_ARABIC_SYRIA 0x0a
583 # endif
584 # ifndef SUBLANG_ARABIC_JORDAN
585 # define SUBLANG_ARABIC_JORDAN 0x0b
586 # endif
587 # ifndef SUBLANG_ARABIC_LEBANON
588 # define SUBLANG_ARABIC_LEBANON 0x0c
589 # endif
590 # ifndef SUBLANG_ARABIC_KUWAIT
591 # define SUBLANG_ARABIC_KUWAIT 0x0d
592 # endif
593 # ifndef SUBLANG_ARABIC_UAE
594 # define SUBLANG_ARABIC_UAE 0x0e
595 # endif
596 # ifndef SUBLANG_ARABIC_BAHRAIN
597 # define SUBLANG_ARABIC_BAHRAIN 0x0f
598 # endif
599 # ifndef SUBLANG_ARABIC_QATAR
600 # define SUBLANG_ARABIC_QATAR 0x10
601 # endif
602 # ifndef SUBLANG_ARMENIAN_ARMENIA
603 # define SUBLANG_ARMENIAN_ARMENIA 0x01
604 # endif
605 # ifndef SUBLANG_ASSAMESE_INDIA
606 # define SUBLANG_ASSAMESE_INDIA 0x01
607 # endif
608 # ifndef SUBLANG_AZERI_LATIN
609 # define SUBLANG_AZERI_LATIN 0x01
610 # endif
611 # ifndef SUBLANG_AZERI_CYRILLIC
612 # define SUBLANG_AZERI_CYRILLIC 0x02
613 # endif
614 # ifndef SUBLANG_BASHKIR_RUSSIA
615 # define SUBLANG_BASHKIR_RUSSIA 0x01
616 # endif
617 # ifndef SUBLANG_BASQUE_BASQUE
618 # define SUBLANG_BASQUE_BASQUE 0x01
619 # endif
620 # ifndef SUBLANG_BELARUSIAN_BELARUS
621 # define SUBLANG_BELARUSIAN_BELARUS 0x01
622 # endif
623 # ifndef SUBLANG_BENGALI_INDIA
624 # define SUBLANG_BENGALI_INDIA 0x01
625 # endif
626 # ifndef SUBLANG_BENGALI_BANGLADESH
627 # define SUBLANG_BENGALI_BANGLADESH 0x02
628 # endif
629 # ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
630 # define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
631 # endif
632 # ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC
633 # define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
634 # endif
635 # ifndef SUBLANG_BRETON_FRANCE
636 # define SUBLANG_BRETON_FRANCE 0x01
637 # endif
638 # ifndef SUBLANG_BULGARIAN_BULGARIA
639 # define SUBLANG_BULGARIAN_BULGARIA 0x01
640 # endif
641 # ifndef SUBLANG_CAMBODIAN_CAMBODIA
642 # define SUBLANG_CAMBODIAN_CAMBODIA 0x01
643 # endif
644 # ifndef SUBLANG_CATALAN_SPAIN
645 # define SUBLANG_CATALAN_SPAIN 0x01
646 # endif
647 # ifndef SUBLANG_CORSICAN_FRANCE
648 # define SUBLANG_CORSICAN_FRANCE 0x01
649 # endif
650 # ifndef SUBLANG_CROATIAN_CROATIA
651 # define SUBLANG_CROATIAN_CROATIA 0x01
652 # endif
653 # ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
654 # define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
655 # endif
656 # ifndef SUBLANG_CHINESE_MACAU
657 # define SUBLANG_CHINESE_MACAU 0x05
658 # endif
659 # ifndef SUBLANG_CZECH_CZECH_REPUBLIC
660 # define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
661 # endif
662 # ifndef SUBLANG_DANISH_DENMARK
663 # define SUBLANG_DANISH_DENMARK 0x01
664 # endif
665 # ifndef SUBLANG_DARI_AFGHANISTAN
666 # define SUBLANG_DARI_AFGHANISTAN 0x01
667 # endif
668 # ifndef SUBLANG_DIVEHI_MALDIVES
669 # define SUBLANG_DIVEHI_MALDIVES 0x01
670 # endif
671 # ifndef SUBLANG_DUTCH_SURINAM
672 # define SUBLANG_DUTCH_SURINAM 0x03
673 # endif
674 # ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
675 # define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
676 # endif
677 # ifndef SUBLANG_ENGLISH_JAMAICA
678 # define SUBLANG_ENGLISH_JAMAICA 0x08
679 # endif
680 # ifndef SUBLANG_ENGLISH_CARIBBEAN
681 # define SUBLANG_ENGLISH_CARIBBEAN 0x09
682 # endif
683 # ifndef SUBLANG_ENGLISH_BELIZE
684 # define SUBLANG_ENGLISH_BELIZE 0x0a
685 # endif
686 # ifndef SUBLANG_ENGLISH_TRINIDAD
687 # define SUBLANG_ENGLISH_TRINIDAD 0x0b
688 # endif
689 # ifndef SUBLANG_ENGLISH_ZIMBABWE
690 # define SUBLANG_ENGLISH_ZIMBABWE 0x0c
691 # endif
692 # ifndef SUBLANG_ENGLISH_PHILIPPINES
693 # define SUBLANG_ENGLISH_PHILIPPINES 0x0d
694 # endif
695 # ifndef SUBLANG_ENGLISH_INDONESIA
696 # define SUBLANG_ENGLISH_INDONESIA 0x0e
697 # endif
698 # ifndef SUBLANG_ENGLISH_HONGKONG
699 # define SUBLANG_ENGLISH_HONGKONG 0x0f
700 # endif
701 # ifndef SUBLANG_ENGLISH_INDIA
702 # define SUBLANG_ENGLISH_INDIA 0x10
703 # endif
704 # ifndef SUBLANG_ENGLISH_MALAYSIA
705 # define SUBLANG_ENGLISH_MALAYSIA 0x11
706 # endif
707 # ifndef SUBLANG_ENGLISH_SINGAPORE
708 # define SUBLANG_ENGLISH_SINGAPORE 0x12
709 # endif
710 # ifndef SUBLANG_ESTONIAN_ESTONIA
711 # define SUBLANG_ESTONIAN_ESTONIA 0x01
712 # endif
713 # ifndef SUBLANG_FAEROESE_FAROE_ISLANDS
714 # define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
715 # endif
716 # ifndef SUBLANG_FARSI_IRAN
717 # define SUBLANG_FARSI_IRAN 0x01
718 # endif
719 # ifndef SUBLANG_FINNISH_FINLAND
720 # define SUBLANG_FINNISH_FINLAND 0x01
721 # endif
722 # ifndef SUBLANG_FRENCH_LUXEMBOURG
723 # define SUBLANG_FRENCH_LUXEMBOURG 0x05
724 # endif
725 # ifndef SUBLANG_FRENCH_MONACO
726 # define SUBLANG_FRENCH_MONACO 0x06
727 # endif
728 # ifndef SUBLANG_FRENCH_WESTINDIES
729 # define SUBLANG_FRENCH_WESTINDIES 0x07
730 # endif
731 # ifndef SUBLANG_FRENCH_REUNION
732 # define SUBLANG_FRENCH_REUNION 0x08
733 # endif
734 # ifndef SUBLANG_FRENCH_CONGO
735 # define SUBLANG_FRENCH_CONGO 0x09
736 # endif
737 # ifndef SUBLANG_FRENCH_SENEGAL
738 # define SUBLANG_FRENCH_SENEGAL 0x0a
739 # endif
740 # ifndef SUBLANG_FRENCH_CAMEROON
741 # define SUBLANG_FRENCH_CAMEROON 0x0b
742 # endif
743 # ifndef SUBLANG_FRENCH_COTEDIVOIRE
744 # define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
745 # endif
746 # ifndef SUBLANG_FRENCH_MALI
747 # define SUBLANG_FRENCH_MALI 0x0d
748 # endif
749 # ifndef SUBLANG_FRENCH_MOROCCO
750 # define SUBLANG_FRENCH_MOROCCO 0x0e
751 # endif
752 # ifndef SUBLANG_FRENCH_HAITI
753 # define SUBLANG_FRENCH_HAITI 0x0f
754 # endif
755 # ifndef SUBLANG_FRISIAN_NETHERLANDS
756 # define SUBLANG_FRISIAN_NETHERLANDS 0x01
757 # endif
758 # ifndef SUBLANG_GALICIAN_SPAIN
759 # define SUBLANG_GALICIAN_SPAIN 0x01
760 # endif
761 # ifndef SUBLANG_GEORGIAN_GEORGIA
762 # define SUBLANG_GEORGIAN_GEORGIA 0x01
763 # endif
764 # ifndef SUBLANG_GERMAN_LUXEMBOURG
765 # define SUBLANG_GERMAN_LUXEMBOURG 0x04
766 # endif
767 # ifndef SUBLANG_GERMAN_LIECHTENSTEIN
768 # define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
769 # endif
770 # ifndef SUBLANG_GREEK_GREECE
771 # define SUBLANG_GREEK_GREECE 0x01
772 # endif
773 # ifndef SUBLANG_GREENLANDIC_GREENLAND
774 # define SUBLANG_GREENLANDIC_GREENLAND 0x01
775 # endif
776 # ifndef SUBLANG_GUJARATI_INDIA
777 # define SUBLANG_GUJARATI_INDIA 0x01
778 # endif
779 # ifndef SUBLANG_HAUSA_NIGERIA_LATIN
780 # define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
781 # endif
782 # ifndef SUBLANG_HEBREW_ISRAEL
783 # define SUBLANG_HEBREW_ISRAEL 0x01
784 # endif
785 # ifndef SUBLANG_HINDI_INDIA
786 # define SUBLANG_HINDI_INDIA 0x01
787 # endif
788 # ifndef SUBLANG_HUNGARIAN_HUNGARY
789 # define SUBLANG_HUNGARIAN_HUNGARY 0x01
790 # endif
791 # ifndef SUBLANG_ICELANDIC_ICELAND
792 # define SUBLANG_ICELANDIC_ICELAND 0x01
793 # endif
794 # ifndef SUBLANG_IGBO_NIGERIA
795 # define SUBLANG_IGBO_NIGERIA 0x01
796 # endif
797 # ifndef SUBLANG_INDONESIAN_INDONESIA
798 # define SUBLANG_INDONESIAN_INDONESIA 0x01
799 # endif
800 # ifndef SUBLANG_INUKTITUT_CANADA
801 # define SUBLANG_INUKTITUT_CANADA 0x01
802 # endif
803 # undef SUBLANG_INUKTITUT_CANADA_LATIN
804 # define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
805 # undef SUBLANG_IRISH_IRELAND
806 # define SUBLANG_IRISH_IRELAND 0x02
807 # ifndef SUBLANG_JAPANESE_JAPAN
808 # define SUBLANG_JAPANESE_JAPAN 0x01
809 # endif
810 # ifndef SUBLANG_KANNADA_INDIA
811 # define SUBLANG_KANNADA_INDIA 0x01
812 # endif
813 # ifndef SUBLANG_KASHMIRI_INDIA
814 # define SUBLANG_KASHMIRI_INDIA 0x02
815 # endif
816 # ifndef SUBLANG_KAZAK_KAZAKHSTAN
817 # define SUBLANG_KAZAK_KAZAKHSTAN 0x01
818 # endif
819 # ifndef SUBLANG_KICHE_GUATEMALA
820 # define SUBLANG_KICHE_GUATEMALA 0x01
821 # endif
822 # ifndef SUBLANG_KINYARWANDA_RWANDA
823 # define SUBLANG_KINYARWANDA_RWANDA 0x01
824 # endif
825 # ifndef SUBLANG_KONKANI_INDIA
826 # define SUBLANG_KONKANI_INDIA 0x01
827 # endif
828 # ifndef SUBLANG_KYRGYZ_KYRGYZSTAN
829 # define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
830 # endif
831 # ifndef SUBLANG_LAO_LAOS
832 # define SUBLANG_LAO_LAOS 0x01
833 # endif
834 # ifndef SUBLANG_LATVIAN_LATVIA
835 # define SUBLANG_LATVIAN_LATVIA 0x01
836 # endif
837 # ifndef SUBLANG_LITHUANIAN_LITHUANIA
838 # define SUBLANG_LITHUANIAN_LITHUANIA 0x01
839 # endif
840 # undef SUBLANG_LOWER_SORBIAN_GERMANY
841 # define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
842 # ifndef SUBLANG_LUXEMBOURGISH_LUXEMBOURG
843 # define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
844 # endif
845 # ifndef SUBLANG_MACEDONIAN_MACEDONIA
846 # define SUBLANG_MACEDONIAN_MACEDONIA 0x01
847 # endif
848 # ifndef SUBLANG_MALAY_MALAYSIA
849 # define SUBLANG_MALAY_MALAYSIA 0x01
850 # endif
851 # ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
852 # define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
853 # endif
854 # ifndef SUBLANG_MALAYALAM_INDIA
855 # define SUBLANG_MALAYALAM_INDIA 0x01
856 # endif
857 # ifndef SUBLANG_MALTESE_MALTA
858 # define SUBLANG_MALTESE_MALTA 0x01
859 # endif
860 # ifndef SUBLANG_MAORI_NEW_ZEALAND
861 # define SUBLANG_MAORI_NEW_ZEALAND 0x01
862 # endif
863 # ifndef SUBLANG_MAPUDUNGUN_CHILE
864 # define SUBLANG_MAPUDUNGUN_CHILE 0x01
865 # endif
866 # ifndef SUBLANG_MARATHI_INDIA
867 # define SUBLANG_MARATHI_INDIA 0x01
868 # endif
869 # ifndef SUBLANG_MOHAWK_CANADA
870 # define SUBLANG_MOHAWK_CANADA 0x01
871 # endif
872 # ifndef SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA
873 # define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
874 # endif
875 # ifndef SUBLANG_MONGOLIAN_PRC
876 # define SUBLANG_MONGOLIAN_PRC 0x02
877 # endif
878 # ifndef SUBLANG_NEPALI_NEPAL
879 # define SUBLANG_NEPALI_NEPAL 0x01
880 # endif
881 # ifndef SUBLANG_NEPALI_INDIA
882 # define SUBLANG_NEPALI_INDIA 0x02
883 # endif
884 # ifndef SUBLANG_OCCITAN_FRANCE
885 # define SUBLANG_OCCITAN_FRANCE 0x01
886 # endif
887 # ifndef SUBLANG_ORIYA_INDIA
888 # define SUBLANG_ORIYA_INDIA 0x01
889 # endif
890 # ifndef SUBLANG_PASHTO_AFGHANISTAN
891 # define SUBLANG_PASHTO_AFGHANISTAN 0x01
892 # endif
893 # ifndef SUBLANG_POLISH_POLAND
894 # define SUBLANG_POLISH_POLAND 0x01
895 # endif
896 # ifndef SUBLANG_PUNJABI_INDIA
897 # define SUBLANG_PUNJABI_INDIA 0x01
898 # endif
899 # ifndef SUBLANG_PUNJABI_PAKISTAN
900 # define SUBLANG_PUNJABI_PAKISTAN 0x02
901 # endif
902 # ifndef SUBLANG_QUECHUA_BOLIVIA
903 # define SUBLANG_QUECHUA_BOLIVIA 0x01
904 # endif
905 # ifndef SUBLANG_QUECHUA_ECUADOR
906 # define SUBLANG_QUECHUA_ECUADOR 0x02
907 # endif
908 # ifndef SUBLANG_QUECHUA_PERU
909 # define SUBLANG_QUECHUA_PERU 0x03
910 # endif
911 # ifndef SUBLANG_ROMANIAN_ROMANIA
912 # define SUBLANG_ROMANIAN_ROMANIA 0x01
913 # endif
914 # ifndef SUBLANG_ROMANIAN_MOLDOVA
915 # define SUBLANG_ROMANIAN_MOLDOVA 0x02
916 # endif
917 # ifndef SUBLANG_ROMANSH_SWITZERLAND
918 # define SUBLANG_ROMANSH_SWITZERLAND 0x01
919 # endif
920 # ifndef SUBLANG_RUSSIAN_RUSSIA
921 # define SUBLANG_RUSSIAN_RUSSIA 0x01
922 # endif
923 # ifndef SUBLANG_RUSSIAN_MOLDAVIA
924 # define SUBLANG_RUSSIAN_MOLDAVIA 0x02
925 # endif
926 # ifndef SUBLANG_SAMI_NORTHERN_NORWAY
927 # define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
928 # endif
929 # ifndef SUBLANG_SAMI_NORTHERN_SWEDEN
930 # define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
931 # endif
932 # ifndef SUBLANG_SAMI_NORTHERN_FINLAND
933 # define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
934 # endif
935 # ifndef SUBLANG_SAMI_LULE_NORWAY
936 # define SUBLANG_SAMI_LULE_NORWAY 0x04
937 # endif
938 # ifndef SUBLANG_SAMI_LULE_SWEDEN
939 # define SUBLANG_SAMI_LULE_SWEDEN 0x05
940 # endif
941 # ifndef SUBLANG_SAMI_SOUTHERN_NORWAY
942 # define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
943 # endif
944 # ifndef SUBLANG_SAMI_SOUTHERN_SWEDEN
945 # define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
946 # endif
947 # undef SUBLANG_SAMI_SKOLT_FINLAND
948 # define SUBLANG_SAMI_SKOLT_FINLAND 0x08
949 # undef SUBLANG_SAMI_INARI_FINLAND
950 # define SUBLANG_SAMI_INARI_FINLAND 0x09
951 # ifndef SUBLANG_SANSKRIT_INDIA
952 # define SUBLANG_SANSKRIT_INDIA 0x01
953 # endif
954 # ifndef SUBLANG_SERBIAN_LATIN
955 # define SUBLANG_SERBIAN_LATIN 0x02
956 # endif
957 # ifndef SUBLANG_SERBIAN_CYRILLIC
958 # define SUBLANG_SERBIAN_CYRILLIC 0x03
959 # endif
960 # ifndef SUBLANG_SINDHI_INDIA
961 # define SUBLANG_SINDHI_INDIA 0x01
962 # endif
963 # undef SUBLANG_SINDHI_PAKISTAN
964 # define SUBLANG_SINDHI_PAKISTAN 0x02
965 # ifndef SUBLANG_SINDHI_AFGHANISTAN
966 # define SUBLANG_SINDHI_AFGHANISTAN 0x02
967 # endif
968 # ifndef SUBLANG_SINHALESE_SRI_LANKA
969 # define SUBLANG_SINHALESE_SRI_LANKA 0x01
970 # endif
971 # ifndef SUBLANG_SLOVAK_SLOVAKIA
972 # define SUBLANG_SLOVAK_SLOVAKIA 0x01
973 # endif
974 # ifndef SUBLANG_SLOVENIAN_SLOVENIA
975 # define SUBLANG_SLOVENIAN_SLOVENIA 0x01
976 # endif
977 # ifndef SUBLANG_SOTHO_SOUTH_AFRICA
978 # define SUBLANG_SOTHO_SOUTH_AFRICA 0x01
979 # endif
980 # ifndef SUBLANG_SPANISH_GUATEMALA
981 # define SUBLANG_SPANISH_GUATEMALA 0x04
982 # endif
983 # ifndef SUBLANG_SPANISH_COSTA_RICA
984 # define SUBLANG_SPANISH_COSTA_RICA 0x05
985 # endif
986 # ifndef SUBLANG_SPANISH_PANAMA
987 # define SUBLANG_SPANISH_PANAMA 0x06
988 # endif
989 # ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
990 # define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
991 # endif
992 # ifndef SUBLANG_SPANISH_VENEZUELA
993 # define SUBLANG_SPANISH_VENEZUELA 0x08
994 # endif
995 # ifndef SUBLANG_SPANISH_COLOMBIA
996 # define SUBLANG_SPANISH_COLOMBIA 0x09
997 # endif
998 # ifndef SUBLANG_SPANISH_PERU
999 # define SUBLANG_SPANISH_PERU 0x0a
1000 # endif
1001 # ifndef SUBLANG_SPANISH_ARGENTINA
1002 # define SUBLANG_SPANISH_ARGENTINA 0x0b
1003 # endif
1004 # ifndef SUBLANG_SPANISH_ECUADOR
1005 # define SUBLANG_SPANISH_ECUADOR 0x0c
1006 # endif
1007 # ifndef SUBLANG_SPANISH_CHILE
1008 # define SUBLANG_SPANISH_CHILE 0x0d
1009 # endif
1010 # ifndef SUBLANG_SPANISH_URUGUAY
1011 # define SUBLANG_SPANISH_URUGUAY 0x0e
1012 # endif
1013 # ifndef SUBLANG_SPANISH_PARAGUAY
1014 # define SUBLANG_SPANISH_PARAGUAY 0x0f
1015 # endif
1016 # ifndef SUBLANG_SPANISH_BOLIVIA
1017 # define SUBLANG_SPANISH_BOLIVIA 0x10
1018 # endif
1019 # ifndef SUBLANG_SPANISH_EL_SALVADOR
1020 # define SUBLANG_SPANISH_EL_SALVADOR 0x11
1021 # endif
1022 # ifndef SUBLANG_SPANISH_HONDURAS
1023 # define SUBLANG_SPANISH_HONDURAS 0x12
1024 # endif
1025 # ifndef SUBLANG_SPANISH_NICARAGUA
1026 # define SUBLANG_SPANISH_NICARAGUA 0x13
1027 # endif
1028 # ifndef SUBLANG_SPANISH_PUERTO_RICO
1029 # define SUBLANG_SPANISH_PUERTO_RICO 0x14
1030 # endif
1031 # ifndef SUBLANG_SPANISH_US
1032 # define SUBLANG_SPANISH_US 0x15
1033 # endif
1034 # ifndef SUBLANG_SWAHILI_KENYA
1035 # define SUBLANG_SWAHILI_KENYA 0x01
1036 # endif
1037 # ifndef SUBLANG_SWEDISH_SWEDEN
1038 # define SUBLANG_SWEDISH_SWEDEN 0x01
1039 # endif
1040 # ifndef SUBLANG_SWEDISH_FINLAND
1041 # define SUBLANG_SWEDISH_FINLAND 0x02
1042 # endif
1043 # ifndef SUBLANG_SYRIAC_SYRIA
1044 # define SUBLANG_SYRIAC_SYRIA 0x01
1045 # endif
1046 # ifndef SUBLANG_TAGALOG_PHILIPPINES
1047 # define SUBLANG_TAGALOG_PHILIPPINES 0x01
1048 # endif
1049 # ifndef SUBLANG_TAJIK_TAJIKISTAN
1050 # define SUBLANG_TAJIK_TAJIKISTAN 0x01
1051 # endif
1052 # ifndef SUBLANG_TAMAZIGHT_ARABIC
1053 # define SUBLANG_TAMAZIGHT_ARABIC 0x01
1054 # endif
1055 # ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN
1056 # define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
1057 # endif
1058 # ifndef SUBLANG_TAMIL_INDIA
1059 # define SUBLANG_TAMIL_INDIA 0x01
1060 # endif
1061 # ifndef SUBLANG_TATAR_RUSSIA
1062 # define SUBLANG_TATAR_RUSSIA 0x01
1063 # endif
1064 # ifndef SUBLANG_TELUGU_INDIA
1065 # define SUBLANG_TELUGU_INDIA 0x01
1066 # endif
1067 # ifndef SUBLANG_THAI_THAILAND
1068 # define SUBLANG_THAI_THAILAND 0x01
1069 # endif
1070 # ifndef SUBLANG_TIBETAN_PRC
1071 # define SUBLANG_TIBETAN_PRC 0x01
1072 # endif
1073 # undef SUBLANG_TIBETAN_BHUTAN
1074 # define SUBLANG_TIBETAN_BHUTAN 0x02
1075 # ifndef SUBLANG_TIGRINYA_ETHIOPIA
1076 # define SUBLANG_TIGRINYA_ETHIOPIA 0x01
1077 # endif
1078 # ifndef SUBLANG_TIGRINYA_ERITREA
1079 # define SUBLANG_TIGRINYA_ERITREA 0x02
1080 # endif
1081 # ifndef SUBLANG_TSWANA_SOUTH_AFRICA
1082 # define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
1083 # endif
1084 # ifndef SUBLANG_TURKISH_TURKEY
1085 # define SUBLANG_TURKISH_TURKEY 0x01
1086 # endif
1087 # ifndef SUBLANG_TURKMEN_TURKMENISTAN
1088 # define SUBLANG_TURKMEN_TURKMENISTAN 0x01
1089 # endif
1090 # ifndef SUBLANG_UIGHUR_PRC
1091 # define SUBLANG_UIGHUR_PRC 0x01
1092 # endif
1093 # ifndef SUBLANG_UKRAINIAN_UKRAINE
1094 # define SUBLANG_UKRAINIAN_UKRAINE 0x01
1095 # endif
1096 # ifndef SUBLANG_UPPER_SORBIAN_GERMANY
1097 # define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
1098 # endif
1099 # ifndef SUBLANG_URDU_PAKISTAN
1100 # define SUBLANG_URDU_PAKISTAN 0x01
1101 # endif
1102 # ifndef SUBLANG_URDU_INDIA
1103 # define SUBLANG_URDU_INDIA 0x02
1104 # endif
1105 # ifndef SUBLANG_UZBEK_LATIN
1106 # define SUBLANG_UZBEK_LATIN 0x01
1107 # endif
1108 # ifndef SUBLANG_UZBEK_CYRILLIC
1109 # define SUBLANG_UZBEK_CYRILLIC 0x02
1110 # endif
1111 # ifndef SUBLANG_VIETNAMESE_VIETNAM
1112 # define SUBLANG_VIETNAMESE_VIETNAM 0x01
1113 # endif
1114 # ifndef SUBLANG_WELSH_UNITED_KINGDOM
1115 # define SUBLANG_WELSH_UNITED_KINGDOM 0x01
1116 # endif
1117 # ifndef SUBLANG_WOLOF_SENEGAL
1118 # define SUBLANG_WOLOF_SENEGAL 0x01
1119 # endif
1120 # ifndef SUBLANG_XHOSA_SOUTH_AFRICA
1121 # define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
1122 # endif
1123 # ifndef SUBLANG_YAKUT_RUSSIA
1124 # define SUBLANG_YAKUT_RUSSIA 0x01
1125 # endif
1126 # ifndef SUBLANG_YI_PRC
1127 # define SUBLANG_YI_PRC 0x01
1128 # endif
1129 # ifndef SUBLANG_YORUBA_NIGERIA
1130 # define SUBLANG_YORUBA_NIGERIA 0x01
1131 # endif
1132 # ifndef SUBLANG_ZULU_SOUTH_AFRICA
1133 # define SUBLANG_ZULU_SOUTH_AFRICA 0x01
1134 # endif
1135 /* GetLocaleInfoA operations. */
1136 # ifndef LOCALE_SNAME
1137 # define LOCALE_SNAME 0x5c
1138 # endif
1139 # ifndef LOCALE_NAME_MAX_LENGTH
1140 # define LOCALE_NAME_MAX_LENGTH 85
1141 # endif
1142 #endif
1145 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
1146 /* Mac OS X 10.2 or newer */
1148 /* Canonicalize a Mac OS X locale name to a Unix locale name.
1149 NAME is a sufficiently large buffer.
1150 On input, it contains the Mac OS X locale name.
1151 On output, it contains the Unix locale name. */
1152 # if !defined IN_LIBINTL
1153 static
1154 # endif
1155 void
1156 gl_locale_name_canonicalize (char *name)
1158 /* This conversion is based on a posting by
1159 Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08,
1160 http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
1162 /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
1163 ISO 3166) names. Prior to Mac OS X 10.3, there is no API for doing this.
1164 Therefore we do it ourselves, using a table based on the results of the
1165 Mac OS X 10.3.8 function
1166 CFLocaleCreateCanonicalLocaleIdentifierFromString(). */
1167 typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
1168 legacy_entry;
1169 static const legacy_entry legacy_table[] = {
1170 { "Afrikaans", "af" },
1171 { "Albanian", "sq" },
1172 { "Amharic", "am" },
1173 { "Arabic", "ar" },
1174 { "Armenian", "hy" },
1175 { "Assamese", "as" },
1176 { "Aymara", "ay" },
1177 { "Azerbaijani", "az" },
1178 { "Basque", "eu" },
1179 { "Belarusian", "be" },
1180 { "Belorussian", "be" },
1181 { "Bengali", "bn" },
1182 { "Brazilian Portugese", "pt_BR" },
1183 { "Brazilian Portuguese", "pt_BR" },
1184 { "Breton", "br" },
1185 { "Bulgarian", "bg" },
1186 { "Burmese", "my" },
1187 { "Byelorussian", "be" },
1188 { "Catalan", "ca" },
1189 { "Chewa", "ny" },
1190 { "Chichewa", "ny" },
1191 { "Chinese", "zh" },
1192 { "Chinese, Simplified", "zh_CN" },
1193 { "Chinese, Traditional", "zh_TW" },
1194 { "Chinese, Tradtional", "zh_TW" },
1195 { "Croatian", "hr" },
1196 { "Czech", "cs" },
1197 { "Danish", "da" },
1198 { "Dutch", "nl" },
1199 { "Dzongkha", "dz" },
1200 { "English", "en" },
1201 { "Esperanto", "eo" },
1202 { "Estonian", "et" },
1203 { "Faroese", "fo" },
1204 { "Farsi", "fa" },
1205 { "Finnish", "fi" },
1206 { "Flemish", "nl_BE" },
1207 { "French", "fr" },
1208 { "Galician", "gl" },
1209 { "Gallegan", "gl" },
1210 { "Georgian", "ka" },
1211 { "German", "de" },
1212 { "Greek", "el" },
1213 { "Greenlandic", "kl" },
1214 { "Guarani", "gn" },
1215 { "Gujarati", "gu" },
1216 { "Hawaiian", "haw" }, /* Yes, "haw", not "cpe". */
1217 { "Hebrew", "he" },
1218 { "Hindi", "hi" },
1219 { "Hungarian", "hu" },
1220 { "Icelandic", "is" },
1221 { "Indonesian", "id" },
1222 { "Inuktitut", "iu" },
1223 { "Irish", "ga" },
1224 { "Italian", "it" },
1225 { "Japanese", "ja" },
1226 { "Javanese", "jv" },
1227 { "Kalaallisut", "kl" },
1228 { "Kannada", "kn" },
1229 { "Kashmiri", "ks" },
1230 { "Kazakh", "kk" },
1231 { "Khmer", "km" },
1232 { "Kinyarwanda", "rw" },
1233 { "Kirghiz", "ky" },
1234 { "Korean", "ko" },
1235 { "Kurdish", "ku" },
1236 { "Latin", "la" },
1237 { "Latvian", "lv" },
1238 { "Lithuanian", "lt" },
1239 { "Macedonian", "mk" },
1240 { "Malagasy", "mg" },
1241 { "Malay", "ms" },
1242 { "Malayalam", "ml" },
1243 { "Maltese", "mt" },
1244 { "Manx", "gv" },
1245 { "Marathi", "mr" },
1246 { "Moldavian", "mo" },
1247 { "Mongolian", "mn" },
1248 { "Nepali", "ne" },
1249 { "Norwegian", "nb" }, /* Yes, "nb", not the obsolete "no". */
1250 { "Nyanja", "ny" },
1251 { "Nynorsk", "nn" },
1252 { "Oriya", "or" },
1253 { "Oromo", "om" },
1254 { "Panjabi", "pa" },
1255 { "Pashto", "ps" },
1256 { "Persian", "fa" },
1257 { "Polish", "pl" },
1258 { "Portuguese", "pt" },
1259 { "Portuguese, Brazilian", "pt_BR" },
1260 { "Punjabi", "pa" },
1261 { "Pushto", "ps" },
1262 { "Quechua", "qu" },
1263 { "Romanian", "ro" },
1264 { "Ruanda", "rw" },
1265 { "Rundi", "rn" },
1266 { "Russian", "ru" },
1267 { "Sami", "se_NO" }, /* Not just "se". */
1268 { "Sanskrit", "sa" },
1269 { "Scottish", "gd" },
1270 { "Serbian", "sr" },
1271 { "Simplified Chinese", "zh_CN" },
1272 { "Sindhi", "sd" },
1273 { "Sinhalese", "si" },
1274 { "Slovak", "sk" },
1275 { "Slovenian", "sl" },
1276 { "Somali", "so" },
1277 { "Spanish", "es" },
1278 { "Sundanese", "su" },
1279 { "Swahili", "sw" },
1280 { "Swedish", "sv" },
1281 { "Tagalog", "tl" },
1282 { "Tajik", "tg" },
1283 { "Tajiki", "tg" },
1284 { "Tamil", "ta" },
1285 { "Tatar", "tt" },
1286 { "Telugu", "te" },
1287 { "Thai", "th" },
1288 { "Tibetan", "bo" },
1289 { "Tigrinya", "ti" },
1290 { "Tongan", "to" },
1291 { "Traditional Chinese", "zh_TW" },
1292 { "Turkish", "tr" },
1293 { "Turkmen", "tk" },
1294 { "Uighur", "ug" },
1295 { "Ukrainian", "uk" },
1296 { "Urdu", "ur" },
1297 { "Uzbek", "uz" },
1298 { "Vietnamese", "vi" },
1299 { "Welsh", "cy" },
1300 { "Yiddish", "yi" }
1303 /* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
1304 to Unix (ISO 639 and ISO 3166) names. */
1305 typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
1306 langtag_entry;
1307 static const langtag_entry langtag_table[] = {
1308 /* Mac OS X has "az-Arab", "az-Cyrl", "az-Latn".
1309 The default script for az on Unix is Latin. */
1310 { "az-Latn", "az" },
1311 /* Mac OS X has "ga-dots". Does not yet exist on Unix. */
1312 { "ga-dots", "ga" },
1313 /* Mac OS X has "kk-Cyrl". Does not yet exist on Unix. */
1314 /* Mac OS X has "mn-Cyrl", "mn-Mong".
1315 The default script for mn on Unix is Cyrillic. */
1316 { "mn-Cyrl", "mn" },
1317 /* Mac OS X has "ms-Arab", "ms-Latn".
1318 The default script for ms on Unix is Latin. */
1319 { "ms-Latn", "ms" },
1320 /* Mac OS X has "tg-Cyrl".
1321 The default script for tg on Unix is Cyrillic. */
1322 { "tg-Cyrl", "tg" },
1323 /* Mac OS X has "tk-Cyrl". Does not yet exist on Unix. */
1324 /* Mac OS X has "tt-Cyrl".
1325 The default script for tt on Unix is Cyrillic. */
1326 { "tt-Cyrl", "tt" },
1327 /* Mac OS X has "zh-Hans", "zh-Hant".
1328 Country codes are used to distinguish these on Unix. */
1329 { "zh-Hans", "zh_CN" },
1330 { "zh-Hant", "zh_TW" }
1333 /* Convert script names (ISO 15924) to Unix conventions.
1334 See http://www.unicode.org/iso15924/iso15924-codes.html */
1335 typedef struct { const char script[4+1]; const char unixy[9+1]; }
1336 script_entry;
1337 static const script_entry script_table[] = {
1338 { "Arab", "arabic" },
1339 { "Cyrl", "cyrillic" },
1340 { "Mong", "mongolian" }
1343 /* Step 1: Convert using legacy_table. */
1344 if (name[0] >= 'A' && name[0] <= 'Z')
1346 unsigned int i1, i2;
1347 i1 = 0;
1348 i2 = sizeof (legacy_table) / sizeof (legacy_entry);
1349 while (i2 - i1 > 1)
1351 /* At this point we know that if name occurs in legacy_table,
1352 its index must be >= i1 and < i2. */
1353 unsigned int i = (i1 + i2) >> 1;
1354 const legacy_entry *p = &legacy_table[i];
1355 if (strcmp (name, p->legacy) < 0)
1356 i2 = i;
1357 else
1358 i1 = i;
1360 if (strcmp (name, legacy_table[i1].legacy) == 0)
1362 strcpy (name, legacy_table[i1].unixy);
1363 return;
1367 /* Step 2: Convert using langtag_table and script_table. */
1368 if (strlen (name) == 7 && name[2] == '-')
1370 unsigned int i1, i2;
1371 i1 = 0;
1372 i2 = sizeof (langtag_table) / sizeof (langtag_entry);
1373 while (i2 - i1 > 1)
1375 /* At this point we know that if name occurs in langtag_table,
1376 its index must be >= i1 and < i2. */
1377 unsigned int i = (i1 + i2) >> 1;
1378 const langtag_entry *p = &langtag_table[i];
1379 if (strcmp (name, p->langtag) < 0)
1380 i2 = i;
1381 else
1382 i1 = i;
1384 if (strcmp (name, langtag_table[i1].langtag) == 0)
1386 strcpy (name, langtag_table[i1].unixy);
1387 return;
1390 i1 = 0;
1391 i2 = sizeof (script_table) / sizeof (script_entry);
1392 while (i2 - i1 > 1)
1394 /* At this point we know that if (name + 3) occurs in script_table,
1395 its index must be >= i1 and < i2. */
1396 unsigned int i = (i1 + i2) >> 1;
1397 const script_entry *p = &script_table[i];
1398 if (strcmp (name + 3, p->script) < 0)
1399 i2 = i;
1400 else
1401 i1 = i;
1403 if (strcmp (name + 3, script_table[i1].script) == 0)
1405 name[2] = '@';
1406 strcpy (name + 3, script_table[i1].unixy);
1407 return;
1411 /* Step 3: Convert new-style dash to Unix underscore. */
1413 char *p;
1414 for (p = name; *p != '\0'; p++)
1415 if (*p == '-')
1416 *p = '_';
1420 #endif
1423 #if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
1425 /* Canonicalize a Windows native locale name to a Unix locale name.
1426 NAME is a sufficiently large buffer.
1427 On input, it contains the Windows locale name.
1428 On output, it contains the Unix locale name. */
1429 # if !defined IN_LIBINTL
1430 static
1431 # endif
1432 void
1433 gl_locale_name_canonicalize (char *name)
1435 /* FIXME: This is probably incomplete: it does not handle "zh-Hans" and
1436 "zh-Hant". */
1437 char *p;
1439 for (p = name; *p != '\0'; p++)
1440 if (*p == '-')
1442 *p = '_';
1443 p++;
1444 for (; *p != '\0'; p++)
1446 if (*p >= 'a' && *p <= 'z')
1447 *p += 'A' - 'a';
1448 if (*p == '-')
1450 *p = '\0';
1451 return;
1454 return;
1458 # if !defined IN_LIBINTL
1459 static
1460 # endif
1461 const char *
1462 gl_locale_name_from_win32_LANGID (LANGID langid)
1464 /* Activate the new code only when the GETTEXT_MUI environment variable is
1465 set, for the time being, since the new code is not well tested. */
1466 if (getenv ("GETTEXT_MUI") != NULL)
1468 static char namebuf[256];
1470 /* Query the system's notion of locale name.
1471 On Windows95/98/ME, GetLocaleInfoA returns some incorrect results.
1472 But we don't need to support systems that are so old. */
1473 if (GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), LOCALE_SNAME,
1474 namebuf, sizeof (namebuf) - 1))
1476 /* Convert it to a Unix locale name. */
1477 gl_locale_name_canonicalize (namebuf);
1478 return namebuf;
1481 /* Internet Explorer has an LCID to RFC3066 name mapping stored in
1482 HKEY_CLASSES_ROOT\Mime\Database\Rfc1766. But we better don't use that
1483 since IE's i18n subsystem is known to be inconsistent with the native
1484 Windows base (e.g. they have different character conversion facilities
1485 that produce different results). */
1486 /* Use our own table. */
1488 int primary, sub;
1490 /* Split into language and territory part. */
1491 primary = PRIMARYLANGID (langid);
1492 sub = SUBLANGID (langid);
1494 /* Dispatch on language.
1495 See also http://www.unicode.org/unicode/onlinedat/languages.html .
1496 For details about languages, see http://www.ethnologue.com/ . */
1497 switch (primary)
1499 case LANG_AFRIKAANS:
1500 switch (sub)
1502 case SUBLANG_AFRIKAANS_SOUTH_AFRICA: return "af_ZA";
1504 return "af";
1505 case LANG_ALBANIAN:
1506 switch (sub)
1508 case SUBLANG_ALBANIAN_ALBANIA: return "sq_AL";
1510 return "sq";
1511 case LANG_ALSATIAN:
1512 switch (sub)
1514 case SUBLANG_ALSATIAN_FRANCE: return "gsw_FR";
1516 return "gsw";
1517 case LANG_AMHARIC:
1518 switch (sub)
1520 case SUBLANG_AMHARIC_ETHIOPIA: return "am_ET";
1522 return "am";
1523 case LANG_ARABIC:
1524 switch (sub)
1526 case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
1527 case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
1528 case SUBLANG_ARABIC_EGYPT: return "ar_EG";
1529 case SUBLANG_ARABIC_LIBYA: return "ar_LY";
1530 case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
1531 case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
1532 case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
1533 case SUBLANG_ARABIC_OMAN: return "ar_OM";
1534 case SUBLANG_ARABIC_YEMEN: return "ar_YE";
1535 case SUBLANG_ARABIC_SYRIA: return "ar_SY";
1536 case SUBLANG_ARABIC_JORDAN: return "ar_JO";
1537 case SUBLANG_ARABIC_LEBANON: return "ar_LB";
1538 case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
1539 case SUBLANG_ARABIC_UAE: return "ar_AE";
1540 case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
1541 case SUBLANG_ARABIC_QATAR: return "ar_QA";
1543 return "ar";
1544 case LANG_ARMENIAN:
1545 switch (sub)
1547 case SUBLANG_ARMENIAN_ARMENIA: return "hy_AM";
1549 return "hy";
1550 case LANG_ASSAMESE:
1551 switch (sub)
1553 case SUBLANG_ASSAMESE_INDIA: return "as_IN";
1555 return "as";
1556 case LANG_AZERI:
1557 switch (sub)
1559 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
1560 case 0x1e: return "az@latin";
1561 case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
1562 case 0x1d: return "az@cyrillic";
1563 case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
1565 return "az";
1566 case LANG_BASHKIR:
1567 switch (sub)
1569 case SUBLANG_BASHKIR_RUSSIA: return "ba_RU";
1571 return "ba";
1572 case LANG_BASQUE:
1573 switch (sub)
1575 case SUBLANG_BASQUE_BASQUE: return "eu_ES";
1577 return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
1578 case LANG_BELARUSIAN:
1579 switch (sub)
1581 case SUBLANG_BELARUSIAN_BELARUS: return "be_BY";
1583 return "be";
1584 case LANG_BENGALI:
1585 switch (sub)
1587 case SUBLANG_BENGALI_INDIA: return "bn_IN";
1588 case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
1590 return "bn";
1591 case LANG_BRETON:
1592 switch (sub)
1594 case SUBLANG_BRETON_FRANCE: return "br_FR";
1596 return "br";
1597 case LANG_BULGARIAN:
1598 switch (sub)
1600 case SUBLANG_BULGARIAN_BULGARIA: return "bg_BG";
1602 return "bg";
1603 case LANG_BURMESE:
1604 switch (sub)
1606 case SUBLANG_DEFAULT: return "my_MM";
1608 return "my";
1609 case LANG_CAMBODIAN:
1610 switch (sub)
1612 case SUBLANG_CAMBODIAN_CAMBODIA: return "km_KH";
1614 return "km";
1615 case LANG_CATALAN:
1616 switch (sub)
1618 case SUBLANG_CATALAN_SPAIN: return "ca_ES";
1620 return "ca";
1621 case LANG_CHEROKEE:
1622 switch (sub)
1624 case SUBLANG_DEFAULT: return "chr_US";
1626 return "chr";
1627 case LANG_CHINESE:
1628 switch (sub)
1630 case SUBLANG_CHINESE_TRADITIONAL: case 0x1f: return "zh_TW";
1631 case SUBLANG_CHINESE_SIMPLIFIED: case 0x00: return "zh_CN";
1632 case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; /* traditional */
1633 case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; /* simplified */
1634 case SUBLANG_CHINESE_MACAU: return "zh_MO"; /* traditional */
1636 return "zh";
1637 case LANG_CORSICAN:
1638 switch (sub)
1640 case SUBLANG_CORSICAN_FRANCE: return "co_FR";
1642 return "co";
1643 case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN
1644 * What used to be called Serbo-Croatian
1645 * should really now be two separate
1646 * languages because of political reasons.
1647 * (Says tml, who knows nothing about Serbian
1648 * or Croatian.)
1649 * (I can feel those flames coming already.)
1651 switch (sub)
1653 /* Croatian */
1654 case 0x00: return "hr";
1655 case SUBLANG_CROATIAN_CROATIA: return "hr_HR";
1656 case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: return "hr_BA";
1657 /* Serbian */
1658 case 0x1f: return "sr";
1659 case 0x1c: return "sr"; /* latin */
1660 case SUBLANG_SERBIAN_LATIN: return "sr_CS"; /* latin */
1661 case 0x09: return "sr_RS"; /* latin */
1662 case 0x0b: return "sr_ME"; /* latin */
1663 case 0x06: return "sr_BA"; /* latin */
1664 case 0x1b: return "sr@cyrillic";
1665 case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
1666 case 0x0a: return "sr_RS@cyrillic";
1667 case 0x0c: return "sr_ME@cyrillic";
1668 case 0x07: return "sr_BA@cyrillic";
1669 /* Bosnian */
1670 case 0x1e: return "bs";
1671 case 0x1a: return "bs"; /* latin */
1672 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: return "bs_BA"; /* latin */
1673 case 0x19: return "bs@cyrillic";
1674 case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: return "bs_BA@cyrillic";
1676 return "hr";
1677 case LANG_CZECH:
1678 switch (sub)
1680 case SUBLANG_CZECH_CZECH_REPUBLIC: return "cs_CZ";
1682 return "cs";
1683 case LANG_DANISH:
1684 switch (sub)
1686 case SUBLANG_DANISH_DENMARK: return "da_DK";
1688 return "da";
1689 case LANG_DARI:
1690 /* FIXME: Adjust this when such locales appear on Unix. */
1691 switch (sub)
1693 case SUBLANG_DARI_AFGHANISTAN: return "prs_AF";
1695 return "prs";
1696 case LANG_DIVEHI:
1697 switch (sub)
1699 case SUBLANG_DIVEHI_MALDIVES: return "dv_MV";
1701 return "dv";
1702 case LANG_DUTCH:
1703 switch (sub)
1705 case SUBLANG_DUTCH: return "nl_NL";
1706 case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
1707 case SUBLANG_DUTCH_SURINAM: return "nl_SR";
1709 return "nl";
1710 case LANG_EDO:
1711 switch (sub)
1713 case SUBLANG_DEFAULT: return "bin_NG";
1715 return "bin";
1716 case LANG_ENGLISH:
1717 switch (sub)
1719 /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
1720 * English was the language spoken in England.
1721 * Oh well.
1723 case SUBLANG_ENGLISH_US: return "en_US";
1724 case SUBLANG_ENGLISH_UK: return "en_GB";
1725 case SUBLANG_ENGLISH_AUS: return "en_AU";
1726 case SUBLANG_ENGLISH_CAN: return "en_CA";
1727 case SUBLANG_ENGLISH_NZ: return "en_NZ";
1728 case SUBLANG_ENGLISH_EIRE: return "en_IE";
1729 case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
1730 case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
1731 case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
1732 case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
1733 case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
1734 case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
1735 case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
1736 case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
1737 case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
1738 case SUBLANG_ENGLISH_INDIA: return "en_IN";
1739 case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
1740 case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
1742 return "en";
1743 case LANG_ESTONIAN:
1744 switch (sub)
1746 case SUBLANG_ESTONIAN_ESTONIA: return "et_EE";
1748 return "et";
1749 case LANG_FAEROESE:
1750 switch (sub)
1752 case SUBLANG_FAEROESE_FAROE_ISLANDS: return "fo_FO";
1754 return "fo";
1755 case LANG_FARSI:
1756 switch (sub)
1758 case SUBLANG_FARSI_IRAN: return "fa_IR";
1760 return "fa";
1761 case LANG_FINNISH:
1762 switch (sub)
1764 case SUBLANG_FINNISH_FINLAND: return "fi_FI";
1766 return "fi";
1767 case LANG_FRENCH:
1768 switch (sub)
1770 case SUBLANG_FRENCH: return "fr_FR";
1771 case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
1772 case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
1773 case SUBLANG_FRENCH_SWISS: return "fr_CH";
1774 case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
1775 case SUBLANG_FRENCH_MONACO: return "fr_MC";
1776 case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
1777 case SUBLANG_FRENCH_REUNION: return "fr_RE";
1778 case SUBLANG_FRENCH_CONGO: return "fr_CG";
1779 case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
1780 case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
1781 case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
1782 case SUBLANG_FRENCH_MALI: return "fr_ML";
1783 case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
1784 case SUBLANG_FRENCH_HAITI: return "fr_HT";
1786 return "fr";
1787 case LANG_FRISIAN:
1788 switch (sub)
1790 case SUBLANG_FRISIAN_NETHERLANDS: return "fy_NL";
1792 return "fy";
1793 case LANG_FULFULDE:
1794 /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */
1795 switch (sub)
1797 case SUBLANG_DEFAULT: return "ff_NG";
1799 return "ff";
1800 case LANG_GAELIC:
1801 switch (sub)
1803 case 0x01: /* SCOTTISH */
1804 /* old, superseded by LANG_SCOTTISH_GAELIC */
1805 return "gd_GB";
1806 case SUBLANG_IRISH_IRELAND: return "ga_IE";
1808 return "ga";
1809 case LANG_GALICIAN:
1810 switch (sub)
1812 case SUBLANG_GALICIAN_SPAIN: return "gl_ES";
1814 return "gl";
1815 case LANG_GEORGIAN:
1816 switch (sub)
1818 case SUBLANG_GEORGIAN_GEORGIA: return "ka_GE";
1820 return "ka";
1821 case LANG_GERMAN:
1822 switch (sub)
1824 case SUBLANG_GERMAN: return "de_DE";
1825 case SUBLANG_GERMAN_SWISS: return "de_CH";
1826 case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
1827 case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
1828 case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
1830 return "de";
1831 case LANG_GREEK:
1832 switch (sub)
1834 case SUBLANG_GREEK_GREECE: return "el_GR";
1836 return "el";
1837 case LANG_GREENLANDIC:
1838 switch (sub)
1840 case SUBLANG_GREENLANDIC_GREENLAND: return "kl_GL";
1842 return "kl";
1843 case LANG_GUARANI:
1844 switch (sub)
1846 case SUBLANG_DEFAULT: return "gn_PY";
1848 return "gn";
1849 case LANG_GUJARATI:
1850 switch (sub)
1852 case SUBLANG_GUJARATI_INDIA: return "gu_IN";
1854 return "gu";
1855 case LANG_HAUSA:
1856 switch (sub)
1858 case 0x1f: return "ha";
1859 case SUBLANG_HAUSA_NIGERIA_LATIN: return "ha_NG";
1861 return "ha";
1862 case LANG_HAWAIIAN:
1863 /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
1864 or Hawaii Creole English ("cpe_US", 600000 speakers)? */
1865 switch (sub)
1867 case SUBLANG_DEFAULT: return "cpe_US";
1869 return "cpe";
1870 case LANG_HEBREW:
1871 switch (sub)
1873 case SUBLANG_HEBREW_ISRAEL: return "he_IL";
1875 return "he";
1876 case LANG_HINDI:
1877 switch (sub)
1879 case SUBLANG_HINDI_INDIA: return "hi_IN";
1881 return "hi";
1882 case LANG_HUNGARIAN:
1883 switch (sub)
1885 case SUBLANG_HUNGARIAN_HUNGARY: return "hu_HU";
1887 return "hu";
1888 case LANG_IBIBIO:
1889 switch (sub)
1891 case SUBLANG_DEFAULT: return "nic_NG";
1893 return "nic";
1894 case LANG_ICELANDIC:
1895 switch (sub)
1897 case SUBLANG_ICELANDIC_ICELAND: return "is_IS";
1899 return "is";
1900 case LANG_IGBO:
1901 switch (sub)
1903 case SUBLANG_IGBO_NIGERIA: return "ig_NG";
1905 return "ig";
1906 case LANG_INDONESIAN:
1907 switch (sub)
1909 case SUBLANG_INDONESIAN_INDONESIA: return "id_ID";
1911 return "id";
1912 case LANG_INUKTITUT:
1913 switch (sub)
1915 case 0x1e: return "iu"; /* syllabic */
1916 case SUBLANG_INUKTITUT_CANADA: return "iu_CA"; /* syllabic */
1917 case 0x1f: return "iu@latin";
1918 case SUBLANG_INUKTITUT_CANADA_LATIN: return "iu_CA@latin";
1920 return "iu";
1921 case LANG_ITALIAN:
1922 switch (sub)
1924 case SUBLANG_ITALIAN: return "it_IT";
1925 case SUBLANG_ITALIAN_SWISS: return "it_CH";
1927 return "it";
1928 case LANG_JAPANESE:
1929 switch (sub)
1931 case SUBLANG_JAPANESE_JAPAN: return "ja_JP";
1933 return "ja";
1934 case LANG_KANNADA:
1935 switch (sub)
1937 case SUBLANG_KANNADA_INDIA: return "kn_IN";
1939 return "kn";
1940 case LANG_KANURI:
1941 switch (sub)
1943 case SUBLANG_DEFAULT: return "kr_NG";
1945 return "kr";
1946 case LANG_KASHMIRI:
1947 switch (sub)
1949 case SUBLANG_DEFAULT: return "ks_PK";
1950 case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
1952 return "ks";
1953 case LANG_KAZAK:
1954 switch (sub)
1956 case SUBLANG_KAZAK_KAZAKHSTAN: return "kk_KZ";
1958 return "kk";
1959 case LANG_KICHE:
1960 /* FIXME: Adjust this when such locales appear on Unix. */
1961 switch (sub)
1963 case SUBLANG_KICHE_GUATEMALA: return "qut_GT";
1965 return "qut";
1966 case LANG_KINYARWANDA:
1967 switch (sub)
1969 case SUBLANG_KINYARWANDA_RWANDA: return "rw_RW";
1971 return "rw";
1972 case LANG_KONKANI:
1973 /* FIXME: Adjust this when such locales appear on Unix. */
1974 switch (sub)
1976 case SUBLANG_KONKANI_INDIA: return "kok_IN";
1978 return "kok";
1979 case LANG_KOREAN:
1980 switch (sub)
1982 case SUBLANG_DEFAULT: return "ko_KR";
1984 return "ko";
1985 case LANG_KYRGYZ:
1986 switch (sub)
1988 case SUBLANG_KYRGYZ_KYRGYZSTAN: return "ky_KG";
1990 return "ky";
1991 case LANG_LAO:
1992 switch (sub)
1994 case SUBLANG_LAO_LAOS: return "lo_LA";
1996 return "lo";
1997 case LANG_LATIN:
1998 switch (sub)
2000 case SUBLANG_DEFAULT: return "la_VA";
2002 return "la";
2003 case LANG_LATVIAN:
2004 switch (sub)
2006 case SUBLANG_LATVIAN_LATVIA: return "lv_LV";
2008 return "lv";
2009 case LANG_LITHUANIAN:
2010 switch (sub)
2012 case SUBLANG_LITHUANIAN_LITHUANIA: return "lt_LT";
2014 return "lt";
2015 case LANG_LUXEMBOURGISH:
2016 switch (sub)
2018 case SUBLANG_LUXEMBOURGISH_LUXEMBOURG: return "lb_LU";
2020 return "lb";
2021 case LANG_MACEDONIAN:
2022 switch (sub)
2024 case SUBLANG_MACEDONIAN_MACEDONIA: return "mk_MK";
2026 return "mk";
2027 case LANG_MALAY:
2028 switch (sub)
2030 case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
2031 case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
2033 return "ms";
2034 case LANG_MALAYALAM:
2035 switch (sub)
2037 case SUBLANG_MALAYALAM_INDIA: return "ml_IN";
2039 return "ml";
2040 case LANG_MALTESE:
2041 switch (sub)
2043 case SUBLANG_MALTESE_MALTA: return "mt_MT";
2045 return "mt";
2046 case LANG_MANIPURI:
2047 /* FIXME: Adjust this when such locales appear on Unix. */
2048 switch (sub)
2050 case SUBLANG_DEFAULT: return "mni_IN";
2052 return "mni";
2053 case LANG_MAORI:
2054 switch (sub)
2056 case SUBLANG_MAORI_NEW_ZEALAND: return "mi_NZ";
2058 return "mi";
2059 case LANG_MAPUDUNGUN:
2060 switch (sub)
2062 case SUBLANG_MAPUDUNGUN_CHILE: return "arn_CL";
2064 return "arn";
2065 case LANG_MARATHI:
2066 switch (sub)
2068 case SUBLANG_MARATHI_INDIA: return "mr_IN";
2070 return "mr";
2071 case LANG_MOHAWK:
2072 switch (sub)
2074 case SUBLANG_MOHAWK_CANADA: return "moh_CA";
2076 return "moh";
2077 case LANG_MONGOLIAN:
2078 switch (sub)
2080 case SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: case 0x1e: return "mn_MN";
2081 case SUBLANG_MONGOLIAN_PRC: case 0x1f: return "mn_CN";
2083 return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
2084 case LANG_NEPALI:
2085 switch (sub)
2087 case SUBLANG_NEPALI_NEPAL: return "ne_NP";
2088 case SUBLANG_NEPALI_INDIA: return "ne_IN";
2090 return "ne";
2091 case LANG_NORWEGIAN:
2092 switch (sub)
2094 case 0x1f: return "nb";
2095 case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO";
2096 case 0x1e: return "nn";
2097 case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
2099 return "no";
2100 case LANG_OCCITAN:
2101 switch (sub)
2103 case SUBLANG_OCCITAN_FRANCE: return "oc_FR";
2105 return "oc";
2106 case LANG_ORIYA:
2107 switch (sub)
2109 case SUBLANG_ORIYA_INDIA: return "or_IN";
2111 return "or";
2112 case LANG_OROMO:
2113 switch (sub)
2115 case SUBLANG_DEFAULT: return "om_ET";
2117 return "om";
2118 case LANG_PAPIAMENTU:
2119 switch (sub)
2121 case SUBLANG_DEFAULT: return "pap_AN";
2123 return "pap";
2124 case LANG_PASHTO:
2125 switch (sub)
2127 case SUBLANG_PASHTO_AFGHANISTAN: return "ps_AF";
2129 return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
2130 case LANG_POLISH:
2131 switch (sub)
2133 case SUBLANG_POLISH_POLAND: return "pl_PL";
2135 return "pl";
2136 case LANG_PORTUGUESE:
2137 switch (sub)
2139 /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
2140 Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
2141 case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
2142 case SUBLANG_PORTUGUESE: return "pt_PT";
2144 return "pt";
2145 case LANG_PUNJABI:
2146 switch (sub)
2148 case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
2149 case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
2151 return "pa";
2152 case LANG_QUECHUA:
2153 /* Note: Microsoft uses the non-ISO language code "quz". */
2154 switch (sub)
2156 case SUBLANG_QUECHUA_BOLIVIA: return "qu_BO";
2157 case SUBLANG_QUECHUA_ECUADOR: return "qu_EC";
2158 case SUBLANG_QUECHUA_PERU: return "qu_PE";
2160 return "qu";
2161 case LANG_ROMANIAN:
2162 switch (sub)
2164 case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
2165 case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
2167 return "ro";
2168 case LANG_ROMANSH:
2169 switch (sub)
2171 case SUBLANG_ROMANSH_SWITZERLAND: return "rm_CH";
2173 return "rm";
2174 case LANG_RUSSIAN:
2175 switch (sub)
2177 case SUBLANG_RUSSIAN_RUSSIA: return "ru_RU";
2178 case SUBLANG_RUSSIAN_MOLDAVIA: return "ru_MD";
2180 return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
2181 case LANG_SAMI:
2182 switch (sub)
2184 /* Northern Sami */
2185 case 0x00: return "se";
2186 case SUBLANG_SAMI_NORTHERN_NORWAY: return "se_NO";
2187 case SUBLANG_SAMI_NORTHERN_SWEDEN: return "se_SE";
2188 case SUBLANG_SAMI_NORTHERN_FINLAND: return "se_FI";
2189 /* Lule Sami */
2190 case 0x1f: return "smj";
2191 case SUBLANG_SAMI_LULE_NORWAY: return "smj_NO";
2192 case SUBLANG_SAMI_LULE_SWEDEN: return "smj_SE";
2193 /* Southern Sami */
2194 case 0x1e: return "sma";
2195 case SUBLANG_SAMI_SOUTHERN_NORWAY: return "sma_NO";
2196 case SUBLANG_SAMI_SOUTHERN_SWEDEN: return "sma_SE";
2197 /* Skolt Sami */
2198 case 0x1d: return "sms";
2199 case SUBLANG_SAMI_SKOLT_FINLAND: return "sms_FI";
2200 /* Inari Sami */
2201 case 0x1c: return "smn";
2202 case SUBLANG_SAMI_INARI_FINLAND: return "smn_FI";
2204 return "se"; /* or "smi"? */
2205 case LANG_SANSKRIT:
2206 switch (sub)
2208 case SUBLANG_SANSKRIT_INDIA: return "sa_IN";
2210 return "sa";
2211 case LANG_SCOTTISH_GAELIC:
2212 switch (sub)
2214 case SUBLANG_DEFAULT: return "gd_GB";
2216 return "gd";
2217 case LANG_SINDHI:
2218 switch (sub)
2220 case SUBLANG_SINDHI_INDIA: return "sd_IN";
2221 case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
2222 /*case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF";*/
2224 return "sd";
2225 case LANG_SINHALESE:
2226 switch (sub)
2228 case SUBLANG_SINHALESE_SRI_LANKA: return "si_LK";
2230 return "si";
2231 case LANG_SLOVAK:
2232 switch (sub)
2234 case SUBLANG_SLOVAK_SLOVAKIA: return "sk_SK";
2236 return "sk";
2237 case LANG_SLOVENIAN:
2238 switch (sub)
2240 case SUBLANG_SLOVENIAN_SLOVENIA: return "sl_SI";
2242 return "sl";
2243 case LANG_SOMALI:
2244 switch (sub)
2246 case SUBLANG_DEFAULT: return "so_SO";
2248 return "so";
2249 case LANG_SORBIAN:
2250 /* FIXME: Adjust this when such locales appear on Unix. */
2251 switch (sub)
2253 /* Upper Sorbian */
2254 case 0x00: return "hsb";
2255 case SUBLANG_UPPER_SORBIAN_GERMANY: return "hsb_DE";
2256 /* Lower Sorbian */
2257 case 0x1f: return "dsb";
2258 case SUBLANG_LOWER_SORBIAN_GERMANY: return "dsb_DE";
2260 return "wen";
2261 case LANG_SOTHO:
2262 /* <http://www.microsoft.com/globaldev/reference/lcid-all.mspx> calls
2263 it "Sepedi"; according to
2264 <http://www.ethnologue.com/show_language.asp?code=nso>
2265 <http://www.ethnologue.com/show_language.asp?code=sot>
2266 it's the same as Northern Sotho. */
2267 switch (sub)
2269 case SUBLANG_SOTHO_SOUTH_AFRICA: return "nso_ZA";
2271 return "nso";
2272 case LANG_SPANISH:
2273 switch (sub)
2275 case SUBLANG_SPANISH: return "es_ES";
2276 case SUBLANG_SPANISH_MEXICAN: return "es_MX";
2277 case SUBLANG_SPANISH_MODERN:
2278 return "es_ES@modern"; /* not seen on Unix */
2279 case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
2280 case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
2281 case SUBLANG_SPANISH_PANAMA: return "es_PA";
2282 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
2283 case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
2284 case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
2285 case SUBLANG_SPANISH_PERU: return "es_PE";
2286 case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
2287 case SUBLANG_SPANISH_ECUADOR: return "es_EC";
2288 case SUBLANG_SPANISH_CHILE: return "es_CL";
2289 case SUBLANG_SPANISH_URUGUAY: return "es_UY";
2290 case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
2291 case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
2292 case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
2293 case SUBLANG_SPANISH_HONDURAS: return "es_HN";
2294 case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
2295 case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
2296 case SUBLANG_SPANISH_US: return "es_US";
2298 return "es";
2299 case LANG_SUTU:
2300 switch (sub)
2302 case SUBLANG_DEFAULT: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
2304 return "bnt";
2305 case LANG_SWAHILI:
2306 switch (sub)
2308 case SUBLANG_SWAHILI_KENYA: return "sw_KE";
2310 return "sw";
2311 case LANG_SWEDISH:
2312 switch (sub)
2314 case SUBLANG_SWEDISH_SWEDEN: return "sv_SE";
2315 case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
2317 return "sv";
2318 case LANG_SYRIAC:
2319 switch (sub)
2321 case SUBLANG_SYRIAC_SYRIA: return "syr_SY"; /* An extinct language. */
2323 return "syr";
2324 case LANG_TAGALOG:
2325 switch (sub)
2327 case SUBLANG_TAGALOG_PHILIPPINES: return "tl_PH"; /* or "fil_PH"? */
2329 return "tl"; /* or "fil"? */
2330 case LANG_TAJIK:
2331 switch (sub)
2333 case 0x1f: return "tg";
2334 case SUBLANG_TAJIK_TAJIKISTAN: return "tg_TJ";
2336 return "tg";
2337 case LANG_TAMAZIGHT:
2338 /* Note: Microsoft uses the non-ISO language code "tmz". */
2339 switch (sub)
2341 /* FIXME: Adjust this when Tamazight locales appear on Unix. */
2342 case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
2343 case 0x1f: return "ber@latin";
2344 case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin";
2346 return "ber";
2347 case LANG_TAMIL:
2348 switch (sub)
2350 case SUBLANG_TAMIL_INDIA: return "ta_IN";
2352 return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
2353 case LANG_TATAR:
2354 switch (sub)
2356 case SUBLANG_TATAR_RUSSIA: return "tt_RU";
2358 return "tt";
2359 case LANG_TELUGU:
2360 switch (sub)
2362 case SUBLANG_TELUGU_INDIA: return "te_IN";
2364 return "te";
2365 case LANG_THAI:
2366 switch (sub)
2368 case SUBLANG_THAI_THAILAND: return "th_TH";
2370 return "th";
2371 case LANG_TIBETAN:
2372 switch (sub)
2374 case SUBLANG_TIBETAN_PRC:
2375 /* Most Tibetans would not like "bo_CN". But Tibet does not yet
2376 have a country code of its own. */
2377 return "bo";
2378 case SUBLANG_TIBETAN_BHUTAN: return "bo_BT";
2380 return "bo";
2381 case LANG_TIGRINYA:
2382 switch (sub)
2384 case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
2385 case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
2387 return "ti";
2388 case LANG_TSONGA:
2389 switch (sub)
2391 case SUBLANG_DEFAULT: return "ts_ZA";
2393 return "ts";
2394 case LANG_TSWANA:
2395 /* Spoken in South Africa, Botswana. */
2396 switch (sub)
2398 case SUBLANG_TSWANA_SOUTH_AFRICA: return "tn_ZA";
2400 return "tn";
2401 case LANG_TURKISH:
2402 switch (sub)
2404 case SUBLANG_TURKISH_TURKEY: return "tr_TR";
2406 return "tr";
2407 case LANG_TURKMEN:
2408 switch (sub)
2410 case SUBLANG_TURKMEN_TURKMENISTAN: return "tk_TM";
2412 return "tk";
2413 case LANG_UIGHUR:
2414 switch (sub)
2416 case SUBLANG_UIGHUR_PRC: return "ug_CN";
2418 return "ug";
2419 case LANG_UKRAINIAN:
2420 switch (sub)
2422 case SUBLANG_UKRAINIAN_UKRAINE: return "uk_UA";
2424 return "uk";
2425 case LANG_URDU:
2426 switch (sub)
2428 case SUBLANG_URDU_PAKISTAN: return "ur_PK";
2429 case SUBLANG_URDU_INDIA: return "ur_IN";
2431 return "ur";
2432 case LANG_UZBEK:
2433 switch (sub)
2435 case 0x1f: return "uz";
2436 case SUBLANG_UZBEK_LATIN: return "uz_UZ";
2437 case 0x1e: return "uz@cyrillic";
2438 case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
2440 return "uz";
2441 case LANG_VENDA:
2442 switch (sub)
2444 case SUBLANG_DEFAULT: return "ve_ZA";
2446 return "ve";
2447 case LANG_VIETNAMESE:
2448 switch (sub)
2450 case SUBLANG_VIETNAMESE_VIETNAM: return "vi_VN";
2452 return "vi";
2453 case LANG_WELSH:
2454 switch (sub)
2456 case SUBLANG_WELSH_UNITED_KINGDOM: return "cy_GB";
2458 return "cy";
2459 case LANG_WOLOF:
2460 switch (sub)
2462 case SUBLANG_WOLOF_SENEGAL: return "wo_SN";
2464 return "wo";
2465 case LANG_XHOSA:
2466 switch (sub)
2468 case SUBLANG_XHOSA_SOUTH_AFRICA: return "xh_ZA";
2470 return "xh";
2471 case LANG_YAKUT:
2472 switch (sub)
2474 case SUBLANG_YAKUT_RUSSIA: return "sah_RU";
2476 return "sah";
2477 case LANG_YI:
2478 switch (sub)
2480 case SUBLANG_YI_PRC: return "ii_CN";
2482 return "ii";
2483 case LANG_YIDDISH:
2484 switch (sub)
2486 case SUBLANG_DEFAULT: return "yi_IL";
2488 return "yi";
2489 case LANG_YORUBA:
2490 switch (sub)
2492 case SUBLANG_YORUBA_NIGERIA: return "yo_NG";
2494 return "yo";
2495 case LANG_ZULU:
2496 switch (sub)
2498 case SUBLANG_ZULU_SOUTH_AFRICA: return "zu_ZA";
2500 return "zu";
2501 default: return "C";
2506 # if !defined IN_LIBINTL
2507 static
2508 # endif
2509 const char *
2510 gl_locale_name_from_win32_LCID (LCID lcid)
2512 LANGID langid;
2514 /* Strip off the sorting rules, keep only the language part. */
2515 langid = LANGIDFROMLCID (lcid);
2517 return gl_locale_name_from_win32_LANGID (langid);
2520 # ifdef WINDOWS_NATIVE
2522 /* Two variables to interface between get_lcid and the EnumLocales
2523 callback function below. */
2524 static LCID found_lcid;
2525 static char lname[LC_MAX * (LOCALE_NAME_MAX_LENGTH + 1) + 1];
2527 /* Callback function for EnumLocales. */
2528 static BOOL CALLBACK
2529 enum_locales_fn (LPTSTR locale_num_str)
2531 char *endp;
2532 char locval[2 * LOCALE_NAME_MAX_LENGTH + 1 + 1];
2533 LCID try_lcid = strtoul (locale_num_str, &endp, 16);
2535 if (GetLocaleInfo (try_lcid, LOCALE_SENGLANGUAGE,
2536 locval, LOCALE_NAME_MAX_LENGTH))
2538 strcat (locval, "_");
2539 if (GetLocaleInfo (try_lcid, LOCALE_SENGCOUNTRY,
2540 locval + strlen (locval), LOCALE_NAME_MAX_LENGTH))
2542 size_t locval_len = strlen (locval);
2544 if (strncmp (locval, lname, locval_len) == 0
2545 && (lname[locval_len] == '.'
2546 || lname[locval_len] == '\0'))
2548 found_lcid = try_lcid;
2549 return FALSE;
2553 return TRUE;
2556 /* This lock protects the get_lcid against multiple simultaneous calls. */
2557 gl_lock_define_initialized(static, get_lcid_lock)
2559 /* Return the Locale ID (LCID) number given the locale's name, a
2560 string, in LOCALE_NAME. This works by enumerating all the locales
2561 supported by the system, until we find one whose name matches
2562 LOCALE_NAME. */
2563 static LCID
2564 get_lcid (const char *locale_name)
2566 /* A simple cache. */
2567 static LCID last_lcid;
2568 static char last_locale[1000];
2570 /* Lock while looking for an LCID, to protect access to static
2571 variables: last_lcid, last_locale, found_lcid, and lname. */
2572 gl_lock_lock (get_lcid_lock);
2573 if (last_lcid > 0 && strcmp (locale_name, last_locale) == 0)
2575 gl_lock_unlock (get_lcid_lock);
2576 return last_lcid;
2578 strncpy (lname, locale_name, sizeof (lname) - 1);
2579 lname[sizeof (lname) - 1] = '\0';
2580 found_lcid = 0;
2581 EnumSystemLocales (enum_locales_fn, LCID_SUPPORTED);
2582 if (found_lcid > 0)
2584 last_lcid = found_lcid;
2585 strcpy (last_locale, locale_name);
2587 gl_lock_unlock (get_lcid_lock);
2588 return found_lcid;
2591 # endif
2592 #endif
2595 #if HAVE_USELOCALE /* glibc, Solaris >= 12 or Mac OS X */
2597 /* Simple hash set of strings. We don't want to drag in lots of hash table
2598 code here. */
2600 # define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
2602 /* A hash function for NUL-terminated char* strings using
2603 the method described by Bruno Haible.
2604 See http://www.haible.de/bruno/hashfunc.html. */
2605 static size_t _GL_ATTRIBUTE_PURE
2606 string_hash (const void *x)
2608 const char *s = (const char *) x;
2609 size_t h = 0;
2611 for (; *s; s++)
2612 h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
2614 return h;
2617 /* A hash table of fixed size. Multiple threads can access it read-only
2618 simultaneously, but only one thread can insert into it at the same time. */
2620 /* A node in a hash bucket collision list. */
2621 struct hash_node
2623 struct hash_node * volatile next;
2624 char contents[FLEXIBLE_ARRAY_MEMBER];
2627 # define HASH_TABLE_SIZE 257
2628 static struct hash_node * volatile struniq_hash_table[HASH_TABLE_SIZE]
2629 /* = { NULL, ..., NULL } */;
2631 /* This lock protects the struniq_hash_table against multiple simultaneous
2632 insertions. */
2633 gl_lock_define_initialized(static, struniq_lock)
2635 /* Store a copy of the given string in a string pool with indefinite extent.
2636 Return a pointer to this copy. */
2637 static const char *
2638 struniq (const char *string)
2640 size_t hashcode = string_hash (string);
2641 size_t slot = hashcode % HASH_TABLE_SIZE;
2642 size_t size;
2643 struct hash_node *new_node;
2644 struct hash_node *p;
2645 for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
2646 if (strcmp (p->contents, string) == 0)
2647 return p->contents;
2648 size = strlen (string) + 1;
2649 new_node =
2650 (struct hash_node *)
2651 malloc (FLEXSIZEOF (struct hash_node, contents, size));
2652 if (new_node == NULL)
2653 /* Out of memory. Return a statically allocated string. */
2654 return "C";
2655 memcpy (new_node->contents, string, size);
2656 /* Lock while inserting new_node. */
2657 gl_lock_lock (struniq_lock);
2658 /* Check whether another thread already added the string while we were
2659 waiting on the lock. */
2660 for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
2661 if (strcmp (p->contents, string) == 0)
2663 free (new_node);
2664 new_node = p;
2665 goto done;
2667 /* Really insert new_node into the hash table. Fill new_node entirely first,
2668 because other threads may be iterating over the linked list. */
2669 new_node->next = struniq_hash_table[slot];
2670 struniq_hash_table[slot] = new_node;
2671 done:
2672 /* Unlock after new_node is inserted. */
2673 gl_lock_unlock (struniq_lock);
2674 return new_node->contents;
2677 #endif
2680 #if defined IN_LIBINTL || HAVE_USELOCALE
2682 /* Like gl_locale_name_thread, except that the result is not in storage of
2683 indefinite extent. */
2684 # if !defined IN_LIBINTL
2685 static
2686 # endif
2687 const char *
2688 gl_locale_name_thread_unsafe (int category, const char *categoryname)
2690 # if HAVE_USELOCALE
2692 locale_t thread_locale = uselocale (NULL);
2693 if (thread_locale != LC_GLOBAL_LOCALE)
2695 # if __GLIBC__ >= 2 && !defined __UCLIBC__
2696 /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
2697 glibc < 2.12.
2698 See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>. */
2699 const char *name =
2700 nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
2701 if (name[0] == '\0')
2702 /* Fallback code for glibc < 2.4, which did not implement
2703 nl_langinfo (_NL_LOCALE_NAME (category)). */
2704 name = thread_locale->__names[category];
2705 return name;
2706 # elif defined __FreeBSD__ || (defined __APPLE__ && defined __MACH__)
2707 /* FreeBSD, Mac OS X */
2708 int mask;
2710 switch (category)
2712 case LC_CTYPE:
2713 mask = LC_CTYPE_MASK;
2714 break;
2715 case LC_NUMERIC:
2716 mask = LC_NUMERIC_MASK;
2717 break;
2718 case LC_TIME:
2719 mask = LC_TIME_MASK;
2720 break;
2721 case LC_COLLATE:
2722 mask = LC_COLLATE_MASK;
2723 break;
2724 case LC_MONETARY:
2725 mask = LC_MONETARY_MASK;
2726 break;
2727 case LC_MESSAGES:
2728 mask = LC_MESSAGES_MASK;
2729 break;
2730 default: /* We shouldn't get here. */
2731 return "";
2733 return querylocale (mask, thread_locale);
2734 # elif defined __sun && HAVE_GETLOCALENAME_L
2735 /* Solaris >= 12. */
2736 return getlocalename_l (category, thread_locale);
2737 # elif defined __CYGWIN__
2738 /* Cygwin < 2.6 lacks uselocale and thread-local locales altogether.
2739 Cygwin <= 2.6.1 lacks NL_LOCALE_NAME, requiring peeking inside
2740 an opaque struct. */
2741 # ifdef NL_LOCALE_NAME
2742 return nl_langinfo_l (NL_LOCALE_NAME (category), thread_locale);
2743 # else
2744 /* FIXME: Remove when we can assume new-enough Cygwin. */
2745 struct __locale_t {
2746 char categories[7][32];
2748 return ((struct __locale_t *) thread_locale)->categories[category];
2749 # endif
2750 # elif defined __ANDROID__
2751 return MB_CUR_MAX == 4 ? "C.UTF-8" : "C";
2752 # endif
2755 # endif
2756 return NULL;
2759 #endif
2761 const char *
2762 gl_locale_name_thread (int category, const char *categoryname)
2764 #if HAVE_USELOCALE
2765 const char *name = gl_locale_name_thread_unsafe (category, categoryname);
2766 if (name != NULL)
2767 return struniq (name);
2768 #elif defined WINDOWS_NATIVE
2769 if (LC_MIN <= category && category <= LC_MAX)
2771 char *locname = setlocale (category, NULL);
2772 LCID lcid = 0;
2774 /* If CATEGORY is LC_ALL, the result might be a semi-colon
2775 separated list of locales. We need only one, so we take the
2776 one corresponding to LC_CTYPE, as the most important for
2777 character translations. */
2778 if (strchr (locname, ';'))
2779 locname = setlocale (LC_CTYPE, NULL);
2781 /* Convert locale name to LCID. We don't want to use
2782 LocaleNameToLCID because (a) it is only available since Vista,
2783 and (b) it doesn't accept locale names returned by 'setlocale'. */
2784 lcid = get_lcid (locname);
2786 if (lcid > 0)
2787 return gl_locale_name_from_win32_LCID (lcid);
2789 #endif
2790 return NULL;
2793 /* XPG3 defines the result of 'setlocale (category, NULL)' as:
2794 "Directs 'setlocale()' to query 'category' and return the current
2795 setting of 'local'."
2796 However it does not specify the exact format. Neither do SUSV2 and
2797 ISO C 99. So we can use this feature only on selected systems (e.g.
2798 those using GNU C Library). */
2799 #if defined _LIBC || ((defined __GLIBC__ && __GLIBC__ >= 2) && !defined __UCLIBC__)
2800 # define HAVE_LOCALE_NULL
2801 #endif
2803 const char *
2804 gl_locale_name_posix (int category, const char *categoryname)
2806 /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
2807 On some systems this can be done by the 'setlocale' function itself. */
2808 #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
2809 return setlocale (category, NULL);
2810 #else
2811 /* On other systems we ignore what setlocale reports and instead look at the
2812 environment variables directly. This is necessary
2813 1. on systems which have a facility for customizing the default locale
2814 (Mac OS X, native Windows, Cygwin) and where the system's setlocale()
2815 function ignores this default locale (Mac OS X, Cygwin), in two cases:
2816 a. when the user missed to use the setlocale() override from libintl
2817 (for example by not including <libintl.h>),
2818 b. when setlocale supports only the "C" locale, such as on Cygwin
2819 1.5.x. In this case even the override from libintl cannot help.
2820 2. on all systems where setlocale supports only the "C" locale. */
2821 /* Strictly speaking, it is a POSIX violation to look at the environment
2822 variables regardless whether setlocale has been called or not. POSIX
2823 says:
2824 "For C-language programs, the POSIX locale shall be the
2825 default locale when the setlocale() function is not called."
2826 But we assume that all programs that use internationalized APIs call
2827 setlocale (LC_ALL, ""). */
2828 return gl_locale_name_environ (category, categoryname);
2829 #endif
2832 const char *
2833 gl_locale_name_environ (int category, const char *categoryname)
2835 const char *retval;
2837 /* Setting of LC_ALL overrides all other. */
2838 retval = getenv ("LC_ALL");
2839 if (retval != NULL && retval[0] != '\0')
2840 return retval;
2841 /* Next comes the name of the desired category. */
2842 retval = getenv (categoryname);
2843 if (retval != NULL && retval[0] != '\0')
2844 return retval;
2845 /* Last possibility is the LANG environment variable. */
2846 retval = getenv ("LANG");
2847 if (retval != NULL && retval[0] != '\0')
2849 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
2850 /* Mac OS X 10.2 or newer.
2851 Ignore invalid LANG value set by the Terminal application. */
2852 if (strcmp (retval, "UTF-8") != 0)
2853 #endif
2854 #if defined __CYGWIN__
2855 /* Cygwin.
2856 Ignore dummy LANG value set by ~/.profile. */
2857 if (strcmp (retval, "C.UTF-8") != 0)
2858 #endif
2859 return retval;
2862 return NULL;
2865 const char *
2866 gl_locale_name_default (void)
2868 /* POSIX:2001 says:
2869 "All implementations shall define a locale as the default locale, to be
2870 invoked when no environment variables are set, or set to the empty
2871 string. This default locale can be the POSIX locale or any other
2872 implementation-defined locale. Some implementations may provide
2873 facilities for local installation administrators to set the default
2874 locale, customizing it for each location. POSIX:2001 does not require
2875 such a facility.
2877 The systems with such a facility are Mac OS X and Windows: They provide a
2878 GUI that allows the user to choose a locale.
2879 - On Mac OS X, by default, none of LC_* or LANG are set. Starting with
2880 Mac OS X 10.4 or 10.5, LANG is set for processes launched by the
2881 'Terminal' application (but sometimes to an incorrect value "UTF-8").
2882 When no environment variable is set, setlocale (LC_ALL, "") uses the
2883 "C" locale.
2884 - On native Windows, by default, none of LC_* or LANG are set.
2885 When no environment variable is set, setlocale (LC_ALL, "") uses the
2886 locale chosen by the user.
2887 - On Cygwin 1.5.x, by default, none of LC_* or LANG are set.
2888 When no environment variable is set, setlocale (LC_ALL, "") uses the
2889 "C" locale.
2890 - On Cygwin 1.7, by default, LANG is set to "C.UTF-8" when the default
2891 ~/.profile is executed.
2892 When no environment variable is set, setlocale (LC_ALL, "") uses the
2893 "C.UTF-8" locale, which operates in the same way as the "C" locale.
2896 #if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined WINDOWS_NATIVE || defined __CYGWIN__)
2898 /* The system does not have a way of setting the locale, other than the
2899 POSIX specified environment variables. We use C as default locale. */
2900 return "C";
2902 #else
2904 /* Return an XPG style locale name language[_territory][@modifier].
2905 Don't even bother determining the codeset; it's not useful in this
2906 context, because message catalogs are not specific to a single
2907 codeset. */
2909 # if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
2910 /* Mac OS X 10.2 or newer */
2912 /* Cache the locale name, since CoreFoundation calls are expensive. */
2913 static const char *cached_localename;
2915 if (cached_localename == NULL)
2917 char namebuf[256];
2918 # if HAVE_CFLOCALECOPYCURRENT /* Mac OS X 10.3 or newer */
2919 CFLocaleRef locale = CFLocaleCopyCurrent ();
2920 CFStringRef name = CFLocaleGetIdentifier (locale);
2922 if (CFStringGetCString (name, namebuf, sizeof (namebuf),
2923 kCFStringEncodingASCII))
2925 gl_locale_name_canonicalize (namebuf);
2926 cached_localename = strdup (namebuf);
2928 CFRelease (locale);
2929 # elif HAVE_CFPREFERENCESCOPYAPPVALUE /* Mac OS X 10.2 or newer */
2930 CFTypeRef value =
2931 CFPreferencesCopyAppValue (CFSTR ("AppleLocale"),
2932 kCFPreferencesCurrentApplication);
2933 if (value != NULL
2934 && CFGetTypeID (value) == CFStringGetTypeID ()
2935 && CFStringGetCString ((CFStringRef)value,
2936 namebuf, sizeof (namebuf),
2937 kCFStringEncodingASCII))
2939 gl_locale_name_canonicalize (namebuf);
2940 cached_localename = strdup (namebuf);
2942 # endif
2943 if (cached_localename == NULL)
2944 cached_localename = "C";
2946 return cached_localename;
2949 # endif
2951 # if defined WINDOWS_NATIVE || defined __CYGWIN__ /* Native Windows or Cygwin */
2953 LCID lcid;
2955 /* Use native Windows API locale ID. */
2956 lcid = GetThreadLocale ();
2958 return gl_locale_name_from_win32_LCID (lcid);
2960 # endif
2961 #endif
2964 /* Determine the current locale's name, and canonicalize it into XPG syntax
2965 language[_territory][.codeset][@modifier]
2966 The codeset part in the result is not reliable; the locale_charset()
2967 should be used for codeset information instead.
2968 The result must not be freed; it is statically allocated. */
2970 const char *
2971 gl_locale_name (int category, const char *categoryname)
2973 const char *retval;
2975 retval = gl_locale_name_thread (category, categoryname);
2976 if (retval != NULL)
2977 return retval;
2979 retval = gl_locale_name_posix (category, categoryname);
2980 if (retval != NULL)
2981 return retval;
2983 return gl_locale_name_default ();