1 /* localename.c - Determine the current selected locale.
2 Copyright (C) 1995-1999, 2000-2003, 2007 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public License
6 as published by the Free Software Foundation; either version 2.1,
7 or (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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, see <http://www.gnu.org/licenses/>.
17 /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
18 /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
19 /* Modified for GpgOL use by Werner Koch <wk@gnupg.org>, 2005. */
20 /* Modified for GnuPG use by Werner Koch <wk@gnupg.org>, 2007 */
32 #ifdef HAVE_W32_SYSTEM
34 /* Mingw headers don't have latest language and sublanguage codes. */
35 # ifndef LANG_AFRIKAANS
36 # define LANG_AFRIKAANS 0x36
38 # ifndef LANG_ALBANIAN
39 # define LANG_ALBANIAN 0x1c
42 # define LANG_AMHARIC 0x5e
45 # define LANG_ARABIC 0x01
47 # ifndef LANG_ARMENIAN
48 # define LANG_ARMENIAN 0x2b
50 # ifndef LANG_ASSAMESE
51 # define LANG_ASSAMESE 0x4d
54 # define LANG_AZERI 0x2c
57 # define LANG_BASQUE 0x2d
59 # ifndef LANG_BELARUSIAN
60 # define LANG_BELARUSIAN 0x23
63 # define LANG_BENGALI 0x45
66 # define LANG_BURMESE 0x55
68 # ifndef LANG_CAMBODIAN
69 # define LANG_CAMBODIAN 0x53
72 # define LANG_CATALAN 0x03
74 # ifndef LANG_CHEROKEE
75 # define LANG_CHEROKEE 0x5c
78 # define LANG_DIVEHI 0x65
81 # define LANG_EDO 0x66
83 # ifndef LANG_ESTONIAN
84 # define LANG_ESTONIAN 0x25
86 # ifndef LANG_FAEROESE
87 # define LANG_FAEROESE 0x38
90 # define LANG_FARSI 0x29
93 # define LANG_FRISIAN 0x62
95 # ifndef LANG_FULFULDE
96 # define LANG_FULFULDE 0x67
99 # define LANG_GAELIC 0x3c
101 # ifndef LANG_GALICIAN
102 # define LANG_GALICIAN 0x56
104 # ifndef LANG_GEORGIAN
105 # define LANG_GEORGIAN 0x37
107 # ifndef LANG_GUARANI
108 # define LANG_GUARANI 0x74
110 # ifndef LANG_GUJARATI
111 # define LANG_GUJARATI 0x47
114 # define LANG_HAUSA 0x68
116 # ifndef LANG_HAWAIIAN
117 # define LANG_HAWAIIAN 0x75
120 # define LANG_HEBREW 0x0d
123 # define LANG_HINDI 0x39
126 # define LANG_IBIBIO 0x69
129 # define LANG_IGBO 0x70
131 # ifndef LANG_INDONESIAN
132 # define LANG_INDONESIAN 0x21
134 # ifndef LANG_INUKTITUT
135 # define LANG_INUKTITUT 0x5d
137 # ifndef LANG_KANNADA
138 # define LANG_KANNADA 0x4b
141 # define LANG_KANURI 0x71
143 # ifndef LANG_KASHMIRI
144 # define LANG_KASHMIRI 0x60
147 # define LANG_KAZAK 0x3f
149 # ifndef LANG_KONKANI
150 # define LANG_KONKANI 0x57
153 # define LANG_KYRGYZ 0x40
156 # define LANG_LAO 0x54
159 # define LANG_LATIN 0x76
161 # ifndef LANG_LATVIAN
162 # define LANG_LATVIAN 0x26
164 # ifndef LANG_LITHUANIAN
165 # define LANG_LITHUANIAN 0x27
167 # ifndef LANG_MACEDONIAN
168 # define LANG_MACEDONIAN 0x2f
171 # define LANG_MALAY 0x3e
173 # ifndef LANG_MALAYALAM
174 # define LANG_MALAYALAM 0x4c
176 # ifndef LANG_MALTESE
177 # define LANG_MALTESE 0x3a
179 # ifndef LANG_MANIPURI
180 # define LANG_MANIPURI 0x58
182 # ifndef LANG_MARATHI
183 # define LANG_MARATHI 0x4e
185 # ifndef LANG_MONGOLIAN
186 # define LANG_MONGOLIAN 0x50
189 # define LANG_NEPALI 0x61
192 # define LANG_ORIYA 0x48
195 # define LANG_OROMO 0x72
197 # ifndef LANG_PAPIAMENTU
198 # define LANG_PAPIAMENTU 0x79
201 # define LANG_PASHTO 0x63
203 # ifndef LANG_PUNJABI
204 # define LANG_PUNJABI 0x46
206 # ifndef LANG_RHAETO_ROMANCE
207 # define LANG_RHAETO_ROMANCE 0x17
210 # define LANG_SAAMI 0x3b
212 # ifndef LANG_SANSKRIT
213 # define LANG_SANSKRIT 0x4f
215 # ifndef LANG_SERBIAN
216 # define LANG_SERBIAN 0x1a
219 # define LANG_SINDHI 0x59
221 # ifndef LANG_SINHALESE
222 # define LANG_SINHALESE 0x5b
225 # define LANG_SLOVAK 0x1b
228 # define LANG_SOMALI 0x77
230 # ifndef LANG_SORBIAN
231 # define LANG_SORBIAN 0x2e
234 # define LANG_SUTU 0x30
236 # ifndef LANG_SWAHILI
237 # define LANG_SWAHILI 0x41
240 # define LANG_SYRIAC 0x5a
242 # ifndef LANG_TAGALOG
243 # define LANG_TAGALOG 0x64
246 # define LANG_TAJIK 0x28
248 # ifndef LANG_TAMAZIGHT
249 # define LANG_TAMAZIGHT 0x5f
252 # define LANG_TAMIL 0x49
255 # define LANG_TATAR 0x44
258 # define LANG_TELUGU 0x4a
261 # define LANG_THAI 0x1e
263 # ifndef LANG_TIBETAN
264 # define LANG_TIBETAN 0x51
266 # ifndef LANG_TIGRINYA
267 # define LANG_TIGRINYA 0x73
270 # define LANG_TSONGA 0x31
273 # define LANG_TSWANA 0x32
275 # ifndef LANG_TURKMEN
276 # define LANG_TURKMEN 0x42
278 # ifndef LANG_UKRAINIAN
279 # define LANG_UKRAINIAN 0x22
282 # define LANG_URDU 0x20
285 # define LANG_UZBEK 0x43
288 # define LANG_VENDA 0x33
290 # ifndef LANG_VIETNAMESE
291 # define LANG_VIETNAMESE 0x2a
294 # define LANG_WELSH 0x52
297 # define LANG_XHOSA 0x34
300 # define LANG_YI 0x78
302 # ifndef LANG_YIDDISH
303 # define LANG_YIDDISH 0x3d
306 # define LANG_YORUBA 0x6a
309 # define LANG_ZULU 0x35
311 # ifndef SUBLANG_ARABIC_SAUDI_ARABIA
312 # define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
314 # ifndef SUBLANG_ARABIC_IRAQ
315 # define SUBLANG_ARABIC_IRAQ 0x02
317 # ifndef SUBLANG_ARABIC_EGYPT
318 # define SUBLANG_ARABIC_EGYPT 0x03
320 # ifndef SUBLANG_ARABIC_LIBYA
321 # define SUBLANG_ARABIC_LIBYA 0x04
323 # ifndef SUBLANG_ARABIC_ALGERIA
324 # define SUBLANG_ARABIC_ALGERIA 0x05
326 # ifndef SUBLANG_ARABIC_MOROCCO
327 # define SUBLANG_ARABIC_MOROCCO 0x06
329 # ifndef SUBLANG_ARABIC_TUNISIA
330 # define SUBLANG_ARABIC_TUNISIA 0x07
332 # ifndef SUBLANG_ARABIC_OMAN
333 # define SUBLANG_ARABIC_OMAN 0x08
335 # ifndef SUBLANG_ARABIC_YEMEN
336 # define SUBLANG_ARABIC_YEMEN 0x09
338 # ifndef SUBLANG_ARABIC_SYRIA
339 # define SUBLANG_ARABIC_SYRIA 0x0a
341 # ifndef SUBLANG_ARABIC_JORDAN
342 # define SUBLANG_ARABIC_JORDAN 0x0b
344 # ifndef SUBLANG_ARABIC_LEBANON
345 # define SUBLANG_ARABIC_LEBANON 0x0c
347 # ifndef SUBLANG_ARABIC_KUWAIT
348 # define SUBLANG_ARABIC_KUWAIT 0x0d
350 # ifndef SUBLANG_ARABIC_UAE
351 # define SUBLANG_ARABIC_UAE 0x0e
353 # ifndef SUBLANG_ARABIC_BAHRAIN
354 # define SUBLANG_ARABIC_BAHRAIN 0x0f
356 # ifndef SUBLANG_ARABIC_QATAR
357 # define SUBLANG_ARABIC_QATAR 0x10
359 # ifndef SUBLANG_AZERI_LATIN
360 # define SUBLANG_AZERI_LATIN 0x01
362 # ifndef SUBLANG_AZERI_CYRILLIC
363 # define SUBLANG_AZERI_CYRILLIC 0x02
365 # ifndef SUBLANG_BENGALI_INDIA
366 # define SUBLANG_BENGALI_INDIA 0x01
368 # ifndef SUBLANG_BENGALI_BANGLADESH
369 # define SUBLANG_BENGALI_BANGLADESH 0x02
371 # ifndef SUBLANG_CHINESE_MACAU
372 # define SUBLANG_CHINESE_MACAU 0x05
374 # ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
375 # define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
377 # ifndef SUBLANG_ENGLISH_JAMAICA
378 # define SUBLANG_ENGLISH_JAMAICA 0x08
380 # ifndef SUBLANG_ENGLISH_CARIBBEAN
381 # define SUBLANG_ENGLISH_CARIBBEAN 0x09
383 # ifndef SUBLANG_ENGLISH_BELIZE
384 # define SUBLANG_ENGLISH_BELIZE 0x0a
386 # ifndef SUBLANG_ENGLISH_TRINIDAD
387 # define SUBLANG_ENGLISH_TRINIDAD 0x0b
389 # ifndef SUBLANG_ENGLISH_ZIMBABWE
390 # define SUBLANG_ENGLISH_ZIMBABWE 0x0c
392 # ifndef SUBLANG_ENGLISH_PHILIPPINES
393 # define SUBLANG_ENGLISH_PHILIPPINES 0x0d
395 # ifndef SUBLANG_ENGLISH_INDONESIA
396 # define SUBLANG_ENGLISH_INDONESIA 0x0e
398 # ifndef SUBLANG_ENGLISH_HONGKONG
399 # define SUBLANG_ENGLISH_HONGKONG 0x0f
401 # ifndef SUBLANG_ENGLISH_INDIA
402 # define SUBLANG_ENGLISH_INDIA 0x10
404 # ifndef SUBLANG_ENGLISH_MALAYSIA
405 # define SUBLANG_ENGLISH_MALAYSIA 0x11
407 # ifndef SUBLANG_ENGLISH_SINGAPORE
408 # define SUBLANG_ENGLISH_SINGAPORE 0x12
410 # ifndef SUBLANG_FRENCH_LUXEMBOURG
411 # define SUBLANG_FRENCH_LUXEMBOURG 0x05
413 # ifndef SUBLANG_FRENCH_MONACO
414 # define SUBLANG_FRENCH_MONACO 0x06
416 # ifndef SUBLANG_FRENCH_WESTINDIES
417 # define SUBLANG_FRENCH_WESTINDIES 0x07
419 # ifndef SUBLANG_FRENCH_REUNION
420 # define SUBLANG_FRENCH_REUNION 0x08
422 # ifndef SUBLANG_FRENCH_CONGO
423 # define SUBLANG_FRENCH_CONGO 0x09
425 # ifndef SUBLANG_FRENCH_SENEGAL
426 # define SUBLANG_FRENCH_SENEGAL 0x0a
428 # ifndef SUBLANG_FRENCH_CAMEROON
429 # define SUBLANG_FRENCH_CAMEROON 0x0b
431 # ifndef SUBLANG_FRENCH_COTEDIVOIRE
432 # define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
434 # ifndef SUBLANG_FRENCH_MALI
435 # define SUBLANG_FRENCH_MALI 0x0d
437 # ifndef SUBLANG_FRENCH_MOROCCO
438 # define SUBLANG_FRENCH_MOROCCO 0x0e
440 # ifndef SUBLANG_FRENCH_HAITI
441 # define SUBLANG_FRENCH_HAITI 0x0f
443 # ifndef SUBLANG_GERMAN_LUXEMBOURG
444 # define SUBLANG_GERMAN_LUXEMBOURG 0x04
446 # ifndef SUBLANG_GERMAN_LIECHTENSTEIN
447 # define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
449 # ifndef SUBLANG_KASHMIRI_INDIA
450 # define SUBLANG_KASHMIRI_INDIA 0x02
452 # ifndef SUBLANG_MALAY_MALAYSIA
453 # define SUBLANG_MALAY_MALAYSIA 0x01
455 # ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
456 # define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
458 # ifndef SUBLANG_NEPALI_INDIA
459 # define SUBLANG_NEPALI_INDIA 0x02
461 # ifndef SUBLANG_PUNJABI_INDIA
462 # define SUBLANG_PUNJABI_INDIA 0x01
464 # ifndef SUBLANG_ROMANIAN_ROMANIA
465 # define SUBLANG_ROMANIAN_ROMANIA 0x01
467 # ifndef SUBLANG_SERBIAN_LATIN
468 # define SUBLANG_SERBIAN_LATIN 0x02
470 # ifndef SUBLANG_SERBIAN_CYRILLIC
471 # define SUBLANG_SERBIAN_CYRILLIC 0x03
473 # ifndef SUBLANG_SINDHI_INDIA
474 # define SUBLANG_SINDHI_INDIA 0x00
476 # ifndef SUBLANG_SINDHI_PAKISTAN
477 # define SUBLANG_SINDHI_PAKISTAN 0x01
479 # ifndef SUBLANG_SPANISH_GUATEMALA
480 # define SUBLANG_SPANISH_GUATEMALA 0x04
482 # ifndef SUBLANG_SPANISH_COSTA_RICA
483 # define SUBLANG_SPANISH_COSTA_RICA 0x05
485 # ifndef SUBLANG_SPANISH_PANAMA
486 # define SUBLANG_SPANISH_PANAMA 0x06
488 # ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
489 # define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
491 # ifndef SUBLANG_SPANISH_VENEZUELA
492 # define SUBLANG_SPANISH_VENEZUELA 0x08
494 # ifndef SUBLANG_SPANISH_COLOMBIA
495 # define SUBLANG_SPANISH_COLOMBIA 0x09
497 # ifndef SUBLANG_SPANISH_PERU
498 # define SUBLANG_SPANISH_PERU 0x0a
500 # ifndef SUBLANG_SPANISH_ARGENTINA
501 # define SUBLANG_SPANISH_ARGENTINA 0x0b
503 # ifndef SUBLANG_SPANISH_ECUADOR
504 # define SUBLANG_SPANISH_ECUADOR 0x0c
506 # ifndef SUBLANG_SPANISH_CHILE
507 # define SUBLANG_SPANISH_CHILE 0x0d
509 # ifndef SUBLANG_SPANISH_URUGUAY
510 # define SUBLANG_SPANISH_URUGUAY 0x0e
512 # ifndef SUBLANG_SPANISH_PARAGUAY
513 # define SUBLANG_SPANISH_PARAGUAY 0x0f
515 # ifndef SUBLANG_SPANISH_BOLIVIA
516 # define SUBLANG_SPANISH_BOLIVIA 0x10
518 # ifndef SUBLANG_SPANISH_EL_SALVADOR
519 # define SUBLANG_SPANISH_EL_SALVADOR 0x11
521 # ifndef SUBLANG_SPANISH_HONDURAS
522 # define SUBLANG_SPANISH_HONDURAS 0x12
524 # ifndef SUBLANG_SPANISH_NICARAGUA
525 # define SUBLANG_SPANISH_NICARAGUA 0x13
527 # ifndef SUBLANG_SPANISH_PUERTO_RICO
528 # define SUBLANG_SPANISH_PUERTO_RICO 0x14
530 # ifndef SUBLANG_SWEDISH_FINLAND
531 # define SUBLANG_SWEDISH_FINLAND 0x02
533 # ifndef SUBLANG_TAMAZIGHT_ARABIC
534 # define SUBLANG_TAMAZIGHT_ARABIC 0x01
536 # ifndef SUBLANG_TAMAZIGHT_LATIN
537 # define SUBLANG_TAMAZIGHT_LATIN 0x02
539 # ifndef SUBLANG_TIGRINYA_ETHIOPIA
540 # define SUBLANG_TIGRINYA_ETHIOPIA 0x00
542 # ifndef SUBLANG_TIGRINYA_ERITREA
543 # define SUBLANG_TIGRINYA_ERITREA 0x01
545 # ifndef SUBLANG_URDU_PAKISTAN
546 # define SUBLANG_URDU_PAKISTAN 0x01
548 # ifndef SUBLANG_URDU_INDIA
549 # define SUBLANG_URDU_INDIA 0x02
551 # ifndef SUBLANG_UZBEK_LATIN
552 # define SUBLANG_UZBEK_LATIN 0x01
554 # ifndef SUBLANG_UZBEK_CYRILLIC
555 # define SUBLANG_UZBEK_CYRILLIC 0x02
557 #endif /* HAVE_W32_SYSTEM */
559 /* XPG3 defines the result of 'setlocale (category, NULL)' as:
560 "Directs 'setlocale()' to query 'category' and return the current
562 However it does not specify the exact format. Neither do SUSV2 and
563 ISO C 99. So we can use this feature only on selected systems (e.g.
564 those using GNU C Library). */
565 #if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
566 # define HAVE_LOCALE_NULL
569 /* Use a dummy value for LC_MESSAGES in case it is not defined. This
570 works becuase we always test for HAVE_LC_MESSAGES and the core
571 fucntion takes the category as a string as well. */
572 #ifndef HAVE_LC_MESSAGES
573 #define LC_MESSAGES 0
577 /* Determine the current locale's name, and canonicalize it into XPG syntax
578 language[_territory[.codeset]][@modifier]
579 The codeset part in the result is not reliable; the locale_charset()
580 should be used for codeset information instead.
581 The result must not be freed; it is statically allocated. */
584 do_nl_locale_name (int category
, const char *categoryname
)
588 #ifndef HAVE_W32_SYSTEM
590 /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
591 On some systems this can be done by the 'setlocale' function itself. */
592 # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
593 retval
= setlocale (category
, NULL
);
595 /* Setting of LC_ALL overwrites all other. */
596 retval
= getenv ("LC_ALL");
597 if (retval
== NULL
|| retval
[0] == '\0')
599 /* Next comes the name of the desired category. */
600 retval
= getenv (categoryname
);
601 if (retval
== NULL
|| retval
[0] == '\0')
603 /* Last possibility is the LANG environment variable. */
604 retval
= getenv ("LANG");
605 if (retval
== NULL
|| retval
[0] == '\0')
606 /* We use C as the default domain. POSIX says this is
607 implementation defined. */
615 #else /* HAVE_W32_SYSTEM */
617 /* Return an XPG style locale name language[_territory][@modifier].
618 Don't even bother determining the codeset; it's not useful in this
619 context, because message catalogs are not specific to a single
626 /* Let the user override the system settings through environment
627 variables, as on POSIX systems. */
628 retval
= getenv ("LC_ALL");
629 if (retval
!= NULL
&& retval
[0] != '\0')
631 retval
= getenv (categoryname
);
632 if (retval
!= NULL
&& retval
[0] != '\0')
634 retval
= getenv ("LANG");
635 if (retval
!= NULL
&& retval
[0] != '\0')
638 /* Use native Win32 API locale ID. */
639 lcid
= GetThreadLocale ();
641 /* Strip off the sorting rules, keep only the language part. */
642 langid
= LANGIDFROMLCID (lcid
);
644 /* Split into language and territory part. */
645 primary
= PRIMARYLANGID (langid
);
646 sub
= SUBLANGID (langid
);
648 /* Dispatch on language.
649 See also http://www.unicode.org/unicode/onlinedat/languages.html .
650 For details about languages, see http://www.ethnologue.com/ . */
653 case LANG_AFRIKAANS
: return "af_ZA";
654 case LANG_ALBANIAN
: return "sq_AL";
655 case LANG_AMHARIC
: return "am_ET";
659 case SUBLANG_ARABIC_SAUDI_ARABIA
: return "ar_SA";
660 case SUBLANG_ARABIC_IRAQ
: return "ar_IQ";
661 case SUBLANG_ARABIC_EGYPT
: return "ar_EG";
662 case SUBLANG_ARABIC_LIBYA
: return "ar_LY";
663 case SUBLANG_ARABIC_ALGERIA
: return "ar_DZ";
664 case SUBLANG_ARABIC_MOROCCO
: return "ar_MA";
665 case SUBLANG_ARABIC_TUNISIA
: return "ar_TN";
666 case SUBLANG_ARABIC_OMAN
: return "ar_OM";
667 case SUBLANG_ARABIC_YEMEN
: return "ar_YE";
668 case SUBLANG_ARABIC_SYRIA
: return "ar_SY";
669 case SUBLANG_ARABIC_JORDAN
: return "ar_JO";
670 case SUBLANG_ARABIC_LEBANON
: return "ar_LB";
671 case SUBLANG_ARABIC_KUWAIT
: return "ar_KW";
672 case SUBLANG_ARABIC_UAE
: return "ar_AE";
673 case SUBLANG_ARABIC_BAHRAIN
: return "ar_BH";
674 case SUBLANG_ARABIC_QATAR
: return "ar_QA";
677 case LANG_ARMENIAN
: return "hy_AM";
678 case LANG_ASSAMESE
: return "as_IN";
682 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
683 case SUBLANG_AZERI_LATIN
: return "az_AZ@latin";
684 case SUBLANG_AZERI_CYRILLIC
: return "az_AZ@cyrillic";
688 return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
689 case LANG_BELARUSIAN
: return "be_BY";
693 case SUBLANG_BENGALI_INDIA
: return "bn_IN";
694 case SUBLANG_BENGALI_BANGLADESH
: return "bn_BD";
697 case LANG_BULGARIAN
: return "bg_BG";
698 case LANG_BURMESE
: return "my_MM";
699 case LANG_CAMBODIAN
: return "km_KH";
700 case LANG_CATALAN
: return "ca_ES";
701 case LANG_CHEROKEE
: return "chr_US";
705 case SUBLANG_CHINESE_TRADITIONAL
: return "zh_TW";
706 case SUBLANG_CHINESE_SIMPLIFIED
: return "zh_CN";
707 case SUBLANG_CHINESE_HONGKONG
: return "zh_HK";
708 case SUBLANG_CHINESE_SINGAPORE
: return "zh_SG";
709 case SUBLANG_CHINESE_MACAU
: return "zh_MO";
712 case LANG_CROATIAN
: /* LANG_CROATIAN == LANG_SERBIAN
713 * What used to be called Serbo-Croatian
714 * should really now be two separate
715 * languages because of political reasons.
716 * (Says tml, who knows nothing about Serbian
718 * (I can feel those flames coming already.)
722 case SUBLANG_DEFAULT
: return "hr_HR";
723 case SUBLANG_SERBIAN_LATIN
: return "sr_CS";
724 case SUBLANG_SERBIAN_CYRILLIC
: return "sr_CS@cyrillic";
727 case LANG_CZECH
: return "cs_CZ";
728 case LANG_DANISH
: return "da_DK";
729 case LANG_DIVEHI
: return "div_MV";
733 case SUBLANG_DUTCH
: return "nl_NL";
734 case SUBLANG_DUTCH_BELGIAN
: /* FLEMISH, VLAAMS */ return "nl_BE";
737 case LANG_EDO
: return "bin_NG";
741 /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
742 * English was the language spoken in England.
745 case SUBLANG_ENGLISH_US
: return "en_US";
746 case SUBLANG_ENGLISH_UK
: return "en_GB";
747 case SUBLANG_ENGLISH_AUS
: return "en_AU";
748 case SUBLANG_ENGLISH_CAN
: return "en_CA";
749 case SUBLANG_ENGLISH_NZ
: return "en_NZ";
750 case SUBLANG_ENGLISH_EIRE
: return "en_IE";
751 case SUBLANG_ENGLISH_SOUTH_AFRICA
: return "en_ZA";
752 case SUBLANG_ENGLISH_JAMAICA
: return "en_JM";
753 case SUBLANG_ENGLISH_CARIBBEAN
: return "en_GD"; /* Grenada? */
754 case SUBLANG_ENGLISH_BELIZE
: return "en_BZ";
755 case SUBLANG_ENGLISH_TRINIDAD
: return "en_TT";
756 case SUBLANG_ENGLISH_ZIMBABWE
: return "en_ZW";
757 case SUBLANG_ENGLISH_PHILIPPINES
: return "en_PH";
758 case SUBLANG_ENGLISH_INDONESIA
: return "en_ID";
759 case SUBLANG_ENGLISH_HONGKONG
: return "en_HK";
760 case SUBLANG_ENGLISH_INDIA
: return "en_IN";
761 case SUBLANG_ENGLISH_MALAYSIA
: return "en_MY";
762 case SUBLANG_ENGLISH_SINGAPORE
: return "en_SG";
765 case LANG_ESTONIAN
: return "et_EE";
766 case LANG_FAEROESE
: return "fo_FO";
767 case LANG_FARSI
: return "fa_IR";
768 case LANG_FINNISH
: return "fi_FI";
772 case SUBLANG_FRENCH
: return "fr_FR";
773 case SUBLANG_FRENCH_BELGIAN
: /* WALLOON */ return "fr_BE";
774 case SUBLANG_FRENCH_CANADIAN
: return "fr_CA";
775 case SUBLANG_FRENCH_SWISS
: return "fr_CH";
776 case SUBLANG_FRENCH_LUXEMBOURG
: return "fr_LU";
777 case SUBLANG_FRENCH_MONACO
: return "fr_MC";
778 case SUBLANG_FRENCH_WESTINDIES
: return "fr"; /* Caribbean? */
779 case SUBLANG_FRENCH_REUNION
: return "fr_RE";
780 case SUBLANG_FRENCH_CONGO
: return "fr_CG";
781 case SUBLANG_FRENCH_SENEGAL
: return "fr_SN";
782 case SUBLANG_FRENCH_CAMEROON
: return "fr_CM";
783 case SUBLANG_FRENCH_COTEDIVOIRE
: return "fr_CI";
784 case SUBLANG_FRENCH_MALI
: return "fr_ML";
785 case SUBLANG_FRENCH_MOROCCO
: return "fr_MA";
786 case SUBLANG_FRENCH_HAITI
: return "fr_HT";
789 case LANG_FRISIAN
: return "fy_NL";
790 case LANG_FULFULDE
: return "ful_NG";
794 case 0x01: /* SCOTTISH */ return "gd_GB";
795 case 0x02: /* IRISH */ return "ga_IE";
798 case LANG_GALICIAN
: return "gl_ES";
799 case LANG_GEORGIAN
: return "ka_GE";
803 case SUBLANG_GERMAN
: return "de_DE";
804 case SUBLANG_GERMAN_SWISS
: return "de_CH";
805 case SUBLANG_GERMAN_AUSTRIAN
: return "de_AT";
806 case SUBLANG_GERMAN_LUXEMBOURG
: return "de_LU";
807 case SUBLANG_GERMAN_LIECHTENSTEIN
: return "de_LI";
810 case LANG_GREEK
: return "el_GR";
811 case LANG_GUARANI
: return "gn_PY";
812 case LANG_GUJARATI
: return "gu_IN";
813 case LANG_HAUSA
: return "ha_NG";
815 /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
816 or Hawaii Creole English ("cpe_US", 600000 speakers)? */
818 case LANG_HEBREW
: return "he_IL";
819 case LANG_HINDI
: return "hi_IN";
820 case LANG_HUNGARIAN
: return "hu_HU";
821 case LANG_IBIBIO
: return "nic_NG";
822 case LANG_ICELANDIC
: return "is_IS";
823 case LANG_IGBO
: return "ibo_NG";
824 case LANG_INDONESIAN
: return "id_ID";
825 case LANG_INUKTITUT
: return "iu_CA";
829 case SUBLANG_ITALIAN
: return "it_IT";
830 case SUBLANG_ITALIAN_SWISS
: return "it_CH";
833 case LANG_JAPANESE
: return "ja_JP";
834 case LANG_KANNADA
: return "kn_IN";
835 case LANG_KANURI
: return "kau_NG";
839 case SUBLANG_DEFAULT
: return "ks_PK";
840 case SUBLANG_KASHMIRI_INDIA
: return "ks_IN";
843 case LANG_KAZAK
: return "kk_KZ";
845 /* FIXME: Adjust this when such locales appear on Unix. */
847 case LANG_KOREAN
: return "ko_KR";
848 case LANG_KYRGYZ
: return "ky_KG";
849 case LANG_LAO
: return "lo_LA";
850 case LANG_LATIN
: return "la_VA";
851 case LANG_LATVIAN
: return "lv_LV";
852 case LANG_LITHUANIAN
: return "lt_LT";
853 case LANG_MACEDONIAN
: return "mk_MK";
857 case SUBLANG_MALAY_MALAYSIA
: return "ms_MY";
858 case SUBLANG_MALAY_BRUNEI_DARUSSALAM
: return "ms_BN";
861 case LANG_MALAYALAM
: return "ml_IN";
862 case LANG_MALTESE
: return "mt_MT";
864 /* FIXME: Adjust this when such locales appear on Unix. */
866 case LANG_MARATHI
: return "mr_IN";
868 return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
872 case SUBLANG_DEFAULT
: return "ne_NP";
873 case SUBLANG_NEPALI_INDIA
: return "ne_IN";
879 case SUBLANG_NORWEGIAN_BOKMAL
: return "no_NO";
880 case SUBLANG_NORWEGIAN_NYNORSK
: return "nn_NO";
883 case LANG_ORIYA
: return "or_IN";
884 case LANG_OROMO
: return "om_ET";
885 case LANG_PAPIAMENTU
: return "pap_AN";
887 return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
888 case LANG_POLISH
: return "pl_PL";
889 case LANG_PORTUGUESE
:
892 case SUBLANG_PORTUGUESE
: return "pt_PT";
893 /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
894 Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
895 case SUBLANG_PORTUGUESE_BRAZILIAN
: return "pt_BR";
901 case SUBLANG_PUNJABI_INDIA
: return "pa_IN"; /* Gurmukhi script */
904 case LANG_RHAETO_ROMANCE
: return "rm_CH";
908 case SUBLANG_ROMANIAN_ROMANIA
: return "ro_RO";
912 return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
913 case LANG_SAAMI
: /* actually Northern Sami */ return "se_NO";
914 case LANG_SANSKRIT
: return "sa_IN";
918 case SUBLANG_SINDHI_INDIA
: return "sd_IN";
919 case SUBLANG_SINDHI_PAKISTAN
: return "sd_PK";
922 case LANG_SINHALESE
: return "si_LK";
923 case LANG_SLOVAK
: return "sk_SK";
924 case LANG_SLOVENIAN
: return "sl_SI";
925 case LANG_SOMALI
: return "so_SO";
927 /* FIXME: Adjust this when such locales appear on Unix. */
932 case SUBLANG_SPANISH
: return "es_ES";
933 case SUBLANG_SPANISH_MEXICAN
: return "es_MX";
934 case SUBLANG_SPANISH_MODERN
:
935 return "es_ES@modern"; /* not seen on Unix */
936 case SUBLANG_SPANISH_GUATEMALA
: return "es_GT";
937 case SUBLANG_SPANISH_COSTA_RICA
: return "es_CR";
938 case SUBLANG_SPANISH_PANAMA
: return "es_PA";
939 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC
: return "es_DO";
940 case SUBLANG_SPANISH_VENEZUELA
: return "es_VE";
941 case SUBLANG_SPANISH_COLOMBIA
: return "es_CO";
942 case SUBLANG_SPANISH_PERU
: return "es_PE";
943 case SUBLANG_SPANISH_ARGENTINA
: return "es_AR";
944 case SUBLANG_SPANISH_ECUADOR
: return "es_EC";
945 case SUBLANG_SPANISH_CHILE
: return "es_CL";
946 case SUBLANG_SPANISH_URUGUAY
: return "es_UY";
947 case SUBLANG_SPANISH_PARAGUAY
: return "es_PY";
948 case SUBLANG_SPANISH_BOLIVIA
: return "es_BO";
949 case SUBLANG_SPANISH_EL_SALVADOR
: return "es_SV";
950 case SUBLANG_SPANISH_HONDURAS
: return "es_HN";
951 case SUBLANG_SPANISH_NICARAGUA
: return "es_NI";
952 case SUBLANG_SPANISH_PUERTO_RICO
: return "es_PR";
955 case LANG_SUTU
: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
956 case LANG_SWAHILI
: return "sw_KE";
960 case SUBLANG_DEFAULT
: return "sv_SE";
961 case SUBLANG_SWEDISH_FINLAND
: return "sv_FI";
964 case LANG_SYRIAC
: return "syr_TR"; /* An extinct language. */
965 case LANG_TAGALOG
: return "tl_PH";
966 case LANG_TAJIK
: return "tg_TJ";
970 /* FIXME: Adjust this when Tamazight locales appear on Unix. */
971 case SUBLANG_TAMAZIGHT_ARABIC
: return "ber_MA@arabic";
972 case SUBLANG_TAMAZIGHT_LATIN
: return "ber_MA@latin";
976 return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
977 case LANG_TATAR
: return "tt_RU";
978 case LANG_TELUGU
: return "te_IN";
979 case LANG_THAI
: return "th_TH";
980 case LANG_TIBETAN
: return "bo_CN";
984 case SUBLANG_TIGRINYA_ETHIOPIA
: return "ti_ET";
985 case SUBLANG_TIGRINYA_ERITREA
: return "ti_ER";
988 case LANG_TSONGA
: return "ts_ZA";
989 case LANG_TSWANA
: return "tn_BW";
990 case LANG_TURKISH
: return "tr_TR";
991 case LANG_TURKMEN
: return "tk_TM";
992 case LANG_UKRAINIAN
: return "uk_UA";
996 case SUBLANG_URDU_PAKISTAN
: return "ur_PK";
997 case SUBLANG_URDU_INDIA
: return "ur_IN";
1003 case SUBLANG_UZBEK_LATIN
: return "uz_UZ";
1004 case SUBLANG_UZBEK_CYRILLIC
: return "uz_UZ@cyrillic";
1008 /* FIXME: It's not clear whether Venda has the ISO 639-2 two-letter code
1010 http://www.loc.gov/standards/iso639-2/englangn.html has it, but
1011 http://lcweb.loc.gov/standards/iso639-2/codechanges.html doesn't, */
1012 return "ven_ZA"; /* or "ve_ZA"? */
1013 case LANG_VIETNAMESE
: return "vi_VN";
1014 case LANG_WELSH
: return "cy_GB";
1015 case LANG_XHOSA
: return "xh_ZA";
1016 case LANG_YI
: return "sit_CN";
1017 case LANG_YIDDISH
: return "yi_IL";
1018 case LANG_YORUBA
: return "yo_NG";
1019 case LANG_ZULU
: return "zu_ZA";
1020 default: return "C";
1023 #endif /* HAVE_W32_SYSTEM */
1028 /* Return the locale used for translatable messages. The standard C
1029 and POSIX are locale names are mapped to an empty string. If a
1030 locale can't be found an empty string will be returned. */
1032 gnupg_messages_locale_name (void)
1036 s
= do_nl_locale_name (LC_MESSAGES
, "LC_MESSAGES");
1039 else if (!strcmp (s
, "C") || !strcmp (s
, "POSIX"))