blob: 795a34fb9e619cd1cbb9b71f89bb265412ee6336 [file] [log] [blame]
Jari Aalto31859422009-01-12 13:36:28 +00001/* localename.c - Determine the current selected locale. */
Jari Aaltob80f6442004-07-27 13:29:18 +00002
Jari Aalto31859422009-01-12 13:36:28 +00003/* Copyright (C) 1995-1999, 2000-2002, 2005-2009 Free Software Foundation, Inc.
Jari Aaltob80f6442004-07-27 13:29:18 +00004
Jari Aalto31859422009-01-12 13:36:28 +00005 This file is part of GNU Bash.
6
7 Bash is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 Bash is distributed in the hope that it will be useful,
Jari Aaltob80f6442004-07-27 13:29:18 +000013 but WITHOUT ANY WARRANTY; without even the implied warranty of
Jari Aalto31859422009-01-12 13:36:28 +000014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
Jari Aaltob80f6442004-07-27 13:29:18 +000016
Jari Aalto31859422009-01-12 13:36:28 +000017 You should have received a copy of the GNU General Public License
18 along with Bash. If not, see <http://www.gnu.org/licenses/>.
19*/
Jari Aaltob80f6442004-07-27 13:29:18 +000020
21/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
22/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
23
24#ifdef HAVE_CONFIG_H
25# include <config.h>
26#endif
27
28#include <stdlib.h>
29#include <locale.h>
30
31#if defined _WIN32 || defined __WIN32__
32# undef WIN32 /* avoid warning on mingw32 */
33# define WIN32
34#endif
35
36#ifdef WIN32
37# define WIN32_LEAN_AND_MEAN
38# include <windows.h>
39/* Mingw headers don't have latest language and sublanguage codes. */
40# ifndef LANG_AFRIKAANS
41# define LANG_AFRIKAANS 0x36
42# endif
43# ifndef LANG_ALBANIAN
44# define LANG_ALBANIAN 0x1c
45# endif
46# ifndef LANG_ARABIC
47# define LANG_ARABIC 0x01
48# endif
49# ifndef LANG_ARMENIAN
50# define LANG_ARMENIAN 0x2b
51# endif
52# ifndef LANG_ASSAMESE
53# define LANG_ASSAMESE 0x4d
54# endif
55# ifndef LANG_AZERI
56# define LANG_AZERI 0x2c
57# endif
58# ifndef LANG_BASQUE
59# define LANG_BASQUE 0x2d
60# endif
61# ifndef LANG_BELARUSIAN
62# define LANG_BELARUSIAN 0x23
63# endif
64# ifndef LANG_BENGALI
65# define LANG_BENGALI 0x45
66# endif
67# ifndef LANG_CATALAN
68# define LANG_CATALAN 0x03
69# endif
70# ifndef LANG_DIVEHI
71# define LANG_DIVEHI 0x65
72# endif
73# ifndef LANG_ESTONIAN
74# define LANG_ESTONIAN 0x25
75# endif
76# ifndef LANG_FAEROESE
77# define LANG_FAEROESE 0x38
78# endif
79# ifndef LANG_FARSI
80# define LANG_FARSI 0x29
81# endif
82# ifndef LANG_GALICIAN
83# define LANG_GALICIAN 0x56
84# endif
85# ifndef LANG_GEORGIAN
86# define LANG_GEORGIAN 0x37
87# endif
88# ifndef LANG_GUJARATI
89# define LANG_GUJARATI 0x47
90# endif
91# ifndef LANG_HEBREW
92# define LANG_HEBREW 0x0d
93# endif
94# ifndef LANG_HINDI
95# define LANG_HINDI 0x39
96# endif
97# ifndef LANG_INDONESIAN
98# define LANG_INDONESIAN 0x21
99# endif
100# ifndef LANG_KANNADA
101# define LANG_KANNADA 0x4b
102# endif
103# ifndef LANG_KASHMIRI
104# define LANG_KASHMIRI 0x60
105# endif
106# ifndef LANG_KAZAK
107# define LANG_KAZAK 0x3f
108# endif
109# ifndef LANG_KONKANI
110# define LANG_KONKANI 0x57
111# endif
112# ifndef LANG_KYRGYZ
113# define LANG_KYRGYZ 0x40
114# endif
115# ifndef LANG_LATVIAN
116# define LANG_LATVIAN 0x26
117# endif
118# ifndef LANG_LITHUANIAN
119# define LANG_LITHUANIAN 0x27
120# endif
121# ifndef LANG_MACEDONIAN
122# define LANG_MACEDONIAN 0x2f
123# endif
124# ifndef LANG_MALAY
125# define LANG_MALAY 0x3e
126# endif
127# ifndef LANG_MALAYALAM
128# define LANG_MALAYALAM 0x4c
129# endif
130# ifndef LANG_MANIPURI
131# define LANG_MANIPURI 0x58
132# endif
133# ifndef LANG_MARATHI
134# define LANG_MARATHI 0x4e
135# endif
136# ifndef LANG_MONGOLIAN
137# define LANG_MONGOLIAN 0x50
138# endif
139# ifndef LANG_NEPALI
140# define LANG_NEPALI 0x61
141# endif
142# ifndef LANG_ORIYA
143# define LANG_ORIYA 0x48
144# endif
145# ifndef LANG_PUNJABI
146# define LANG_PUNJABI 0x46
147# endif
148# ifndef LANG_SANSKRIT
149# define LANG_SANSKRIT 0x4f
150# endif
151# ifndef LANG_SERBIAN
152# define LANG_SERBIAN 0x1a
153# endif
154# ifndef LANG_SINDHI
155# define LANG_SINDHI 0x59
156# endif
157# ifndef LANG_SLOVAK
158# define LANG_SLOVAK 0x1b
159# endif
160# ifndef LANG_SORBIAN
161# define LANG_SORBIAN 0x2e
162# endif
163# ifndef LANG_SWAHILI
164# define LANG_SWAHILI 0x41
165# endif
166# ifndef LANG_SYRIAC
167# define LANG_SYRIAC 0x5a
168# endif
169# ifndef LANG_TAMIL
170# define LANG_TAMIL 0x49
171# endif
172# ifndef LANG_TATAR
173# define LANG_TATAR 0x44
174# endif
175# ifndef LANG_TELUGU
176# define LANG_TELUGU 0x4a
177# endif
178# ifndef LANG_THAI
179# define LANG_THAI 0x1e
180# endif
181# ifndef LANG_UKRAINIAN
182# define LANG_UKRAINIAN 0x22
183# endif
184# ifndef LANG_URDU
185# define LANG_URDU 0x20
186# endif
187# ifndef LANG_UZBEK
188# define LANG_UZBEK 0x43
189# endif
190# ifndef LANG_VIETNAMESE
191# define LANG_VIETNAMESE 0x2a
192# endif
193# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
194# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
195# endif
196# ifndef SUBLANG_ARABIC_IRAQ
197# define SUBLANG_ARABIC_IRAQ 0x02
198# endif
199# ifndef SUBLANG_ARABIC_EGYPT
200# define SUBLANG_ARABIC_EGYPT 0x03
201# endif
202# ifndef SUBLANG_ARABIC_LIBYA
203# define SUBLANG_ARABIC_LIBYA 0x04
204# endif
205# ifndef SUBLANG_ARABIC_ALGERIA
206# define SUBLANG_ARABIC_ALGERIA 0x05
207# endif
208# ifndef SUBLANG_ARABIC_MOROCCO
209# define SUBLANG_ARABIC_MOROCCO 0x06
210# endif
211# ifndef SUBLANG_ARABIC_TUNISIA
212# define SUBLANG_ARABIC_TUNISIA 0x07
213# endif
214# ifndef SUBLANG_ARABIC_OMAN
215# define SUBLANG_ARABIC_OMAN 0x08
216# endif
217# ifndef SUBLANG_ARABIC_YEMEN
218# define SUBLANG_ARABIC_YEMEN 0x09
219# endif
220# ifndef SUBLANG_ARABIC_SYRIA
221# define SUBLANG_ARABIC_SYRIA 0x0a
222# endif
223# ifndef SUBLANG_ARABIC_JORDAN
224# define SUBLANG_ARABIC_JORDAN 0x0b
225# endif
226# ifndef SUBLANG_ARABIC_LEBANON
227# define SUBLANG_ARABIC_LEBANON 0x0c
228# endif
229# ifndef SUBLANG_ARABIC_KUWAIT
230# define SUBLANG_ARABIC_KUWAIT 0x0d
231# endif
232# ifndef SUBLANG_ARABIC_UAE
233# define SUBLANG_ARABIC_UAE 0x0e
234# endif
235# ifndef SUBLANG_ARABIC_BAHRAIN
236# define SUBLANG_ARABIC_BAHRAIN 0x0f
237# endif
238# ifndef SUBLANG_ARABIC_QATAR
239# define SUBLANG_ARABIC_QATAR 0x10
240# endif
241# ifndef SUBLANG_AZERI_LATIN
242# define SUBLANG_AZERI_LATIN 0x01
243# endif
244# ifndef SUBLANG_AZERI_CYRILLIC
245# define SUBLANG_AZERI_CYRILLIC 0x02
246# endif
247# ifndef SUBLANG_CHINESE_MACAU
248# define SUBLANG_CHINESE_MACAU 0x05
249# endif
250# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
251# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
252# endif
253# ifndef SUBLANG_ENGLISH_JAMAICA
254# define SUBLANG_ENGLISH_JAMAICA 0x08
255# endif
256# ifndef SUBLANG_ENGLISH_CARIBBEAN
257# define SUBLANG_ENGLISH_CARIBBEAN 0x09
258# endif
259# ifndef SUBLANG_ENGLISH_BELIZE
260# define SUBLANG_ENGLISH_BELIZE 0x0a
261# endif
262# ifndef SUBLANG_ENGLISH_TRINIDAD
263# define SUBLANG_ENGLISH_TRINIDAD 0x0b
264# endif
265# ifndef SUBLANG_ENGLISH_ZIMBABWE
266# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
267# endif
268# ifndef SUBLANG_ENGLISH_PHILIPPINES
269# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
270# endif
271# ifndef SUBLANG_FRENCH_LUXEMBOURG
272# define SUBLANG_FRENCH_LUXEMBOURG 0x05
273# endif
274# ifndef SUBLANG_FRENCH_MONACO
275# define SUBLANG_FRENCH_MONACO 0x06
276# endif
277# ifndef SUBLANG_GERMAN_LUXEMBOURG
278# define SUBLANG_GERMAN_LUXEMBOURG 0x04
279# endif
280# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
281# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
282# endif
283# ifndef SUBLANG_KASHMIRI_INDIA
284# define SUBLANG_KASHMIRI_INDIA 0x02
285# endif
286# ifndef SUBLANG_MALAY_MALAYSIA
287# define SUBLANG_MALAY_MALAYSIA 0x01
288# endif
289# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
290# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
291# endif
292# ifndef SUBLANG_NEPALI_INDIA
293# define SUBLANG_NEPALI_INDIA 0x02
294# endif
295# ifndef SUBLANG_SERBIAN_LATIN
296# define SUBLANG_SERBIAN_LATIN 0x02
297# endif
298# ifndef SUBLANG_SERBIAN_CYRILLIC
299# define SUBLANG_SERBIAN_CYRILLIC 0x03
300# endif
301# ifndef SUBLANG_SPANISH_GUATEMALA
302# define SUBLANG_SPANISH_GUATEMALA 0x04
303# endif
304# ifndef SUBLANG_SPANISH_COSTA_RICA
305# define SUBLANG_SPANISH_COSTA_RICA 0x05
306# endif
307# ifndef SUBLANG_SPANISH_PANAMA
308# define SUBLANG_SPANISH_PANAMA 0x06
309# endif
310# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
311# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
312# endif
313# ifndef SUBLANG_SPANISH_VENEZUELA
314# define SUBLANG_SPANISH_VENEZUELA 0x08
315# endif
316# ifndef SUBLANG_SPANISH_COLOMBIA
317# define SUBLANG_SPANISH_COLOMBIA 0x09
318# endif
319# ifndef SUBLANG_SPANISH_PERU
320# define SUBLANG_SPANISH_PERU 0x0a
321# endif
322# ifndef SUBLANG_SPANISH_ARGENTINA
323# define SUBLANG_SPANISH_ARGENTINA 0x0b
324# endif
325# ifndef SUBLANG_SPANISH_ECUADOR
326# define SUBLANG_SPANISH_ECUADOR 0x0c
327# endif
328# ifndef SUBLANG_SPANISH_CHILE
329# define SUBLANG_SPANISH_CHILE 0x0d
330# endif
331# ifndef SUBLANG_SPANISH_URUGUAY
332# define SUBLANG_SPANISH_URUGUAY 0x0e
333# endif
334# ifndef SUBLANG_SPANISH_PARAGUAY
335# define SUBLANG_SPANISH_PARAGUAY 0x0f
336# endif
337# ifndef SUBLANG_SPANISH_BOLIVIA
338# define SUBLANG_SPANISH_BOLIVIA 0x10
339# endif
340# ifndef SUBLANG_SPANISH_EL_SALVADOR
341# define SUBLANG_SPANISH_EL_SALVADOR 0x11
342# endif
343# ifndef SUBLANG_SPANISH_HONDURAS
344# define SUBLANG_SPANISH_HONDURAS 0x12
345# endif
346# ifndef SUBLANG_SPANISH_NICARAGUA
347# define SUBLANG_SPANISH_NICARAGUA 0x13
348# endif
349# ifndef SUBLANG_SPANISH_PUERTO_RICO
350# define SUBLANG_SPANISH_PUERTO_RICO 0x14
351# endif
352# ifndef SUBLANG_SWEDISH_FINLAND
353# define SUBLANG_SWEDISH_FINLAND 0x02
354# endif
355# ifndef SUBLANG_URDU_PAKISTAN
356# define SUBLANG_URDU_PAKISTAN 0x01
357# endif
358# ifndef SUBLANG_URDU_INDIA
359# define SUBLANG_URDU_INDIA 0x02
360# endif
361# ifndef SUBLANG_UZBEK_LATIN
362# define SUBLANG_UZBEK_LATIN 0x01
363# endif
364# ifndef SUBLANG_UZBEK_CYRILLIC
365# define SUBLANG_UZBEK_CYRILLIC 0x02
366# endif
367#endif
368
369/* XPG3 defines the result of 'setlocale (category, NULL)' as:
370 "Directs 'setlocale()' to query 'category' and return the current
371 setting of 'local'."
372 However it does not specify the exact format. Neither do SUSV2 and
373 ISO C 99. So we can use this feature only on selected systems (e.g.
374 those using GNU C Library). */
375#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
376# define HAVE_LOCALE_NULL
377#endif
378
379/* Determine the current locale's name, and canonicalize it into XPG syntax
380 language[_territory[.codeset]][@modifier]
381 The codeset part in the result is not reliable; the locale_charset()
382 should be used for codeset information instead.
383 The result must not be freed; it is statically allocated. */
384
385const char *
386_nl_locale_name (category, categoryname)
387 int category;
388 const char *categoryname;
389{
390 const char *retval;
391
392#ifndef WIN32
393
394 /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
395 On some systems this can be done by the 'setlocale' function itself. */
396# if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
397 retval = setlocale (category, NULL);
398# else
399 /* Setting of LC_ALL overwrites all other. */
400 retval = getenv ("LC_ALL");
401 if (retval == NULL || retval[0] == '\0')
402 {
403 /* Next comes the name of the desired category. */
404 retval = getenv (categoryname);
405 if (retval == NULL || retval[0] == '\0')
406 {
407 /* Last possibility is the LANG environment variable. */
408 retval = getenv ("LANG");
409 if (retval == NULL || retval[0] == '\0')
410 /* We use C as the default domain. POSIX says this is
411 implementation defined. */
412 retval = "C";
413 }
414 }
415# endif
416
417 return retval;
418
419#else /* WIN32 */
420
421 /* Return an XPG style locale name language[_territory][@modifier].
422 Don't even bother determining the codeset; it's not useful in this
423 context, because message catalogs are not specific to a single
424 codeset. */
425
426 LCID lcid;
427 LANGID langid;
428 int primary, sub;
429
430 /* Let the user override the system settings through environment
431 variables, as on POSIX systems. */
432 retval = getenv ("LC_ALL");
433 if (retval != NULL && retval[0] != '\0')
434 return retval;
435 retval = getenv (categoryname);
436 if (retval != NULL && retval[0] != '\0')
437 return retval;
438 retval = getenv ("LANG");
439 if (retval != NULL && retval[0] != '\0')
440 return retval;
441
442 /* Use native Win32 API locale ID. */
443 lcid = GetThreadLocale ();
444
445 /* Strip off the sorting rules, keep only the language part. */
446 langid = LANGIDFROMLCID (lcid);
447
448 /* Split into language and territory part. */
449 primary = PRIMARYLANGID (langid);
450 sub = SUBLANGID (langid);
451
452 /* Dispatch on language.
453 See also http://www.unicode.org/unicode/onlinedat/languages.html .
454 For details about languages, see http://www.ethnologue.com/ . */
455 switch (primary)
456 {
457 case LANG_AFRIKAANS: return "af_ZA";
458 case LANG_ALBANIAN: return "sq_AL";
459 case 0x5e: /* AMHARIC */ return "am_ET";
460 case LANG_ARABIC:
461 switch (sub)
462 {
463 case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
464 case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
465 case SUBLANG_ARABIC_EGYPT: return "ar_EG";
466 case SUBLANG_ARABIC_LIBYA: return "ar_LY";
467 case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
468 case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
469 case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
470 case SUBLANG_ARABIC_OMAN: return "ar_OM";
471 case SUBLANG_ARABIC_YEMEN: return "ar_YE";
472 case SUBLANG_ARABIC_SYRIA: return "ar_SY";
473 case SUBLANG_ARABIC_JORDAN: return "ar_JO";
474 case SUBLANG_ARABIC_LEBANON: return "ar_LB";
475 case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
476 case SUBLANG_ARABIC_UAE: return "ar_AE";
477 case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
478 case SUBLANG_ARABIC_QATAR: return "ar_QA";
479 }
480 return "ar";
481 case LANG_ARMENIAN: return "hy_AM";
482 case LANG_ASSAMESE: return "as_IN";
483 case LANG_AZERI:
484 switch (sub)
485 {
486 /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
487 case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
488 case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
489 }
490 return "az";
491 case LANG_BASQUE:
492 return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
493 case LANG_BELARUSIAN: return "be_BY";
494 case LANG_BENGALI: return "bn_IN";
495 case LANG_BULGARIAN: return "bg_BG";
496 case 0x55: /* BURMESE */ return "my_MM";
497 case 0x53: /* CAMBODIAN */ return "km_KH";
498 case LANG_CATALAN: return "ca_ES";
499 case 0x5c: /* CHEROKEE */ return "chr_US";
500 case LANG_CHINESE:
501 switch (sub)
502 {
503 case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
504 case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
505 case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
506 case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
507 case SUBLANG_CHINESE_MACAU: return "zh_MO";
508 }
509 return "zh";
510 case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
511 * What used to be called Serbo-Croatian
512 * should really now be two separate
513 * languages because of political reasons.
514 * (Says tml, who knows nothing about Serbian
515 * or Croatian.)
516 * (I can feel those flames coming already.)
517 */
518 switch (sub)
519 {
520 case SUBLANG_DEFAULT: return "hr_HR";
521 case SUBLANG_SERBIAN_LATIN: return "sr_YU";
522 case SUBLANG_SERBIAN_CYRILLIC: return "sr_YU@cyrillic";
523 }
524 return "hr";
525 case LANG_CZECH: return "cs_CZ";
526 case LANG_DANISH: return "da_DK";
527 case LANG_DIVEHI: return "div_MV";
528 case LANG_DUTCH:
529 switch (sub)
530 {
531 case SUBLANG_DUTCH: return "nl_NL";
532 case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
533 }
534 return "nl";
535 case 0x66: /* EDO */ return "bin_NG";
536 case LANG_ENGLISH:
537 switch (sub)
538 {
539 /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
540 * English was the language spoken in England.
541 * Oh well.
542 */
543 case SUBLANG_ENGLISH_US: return "en_US";
544 case SUBLANG_ENGLISH_UK: return "en_GB";
545 case SUBLANG_ENGLISH_AUS: return "en_AU";
546 case SUBLANG_ENGLISH_CAN: return "en_CA";
547 case SUBLANG_ENGLISH_NZ: return "en_NZ";
548 case SUBLANG_ENGLISH_EIRE: return "en_IE";
549 case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
550 case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
551 case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
552 case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
553 case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
554 case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
555 case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
556 }
557 return "en";
558 case LANG_ESTONIAN: return "et_EE";
559 case LANG_FAEROESE: return "fo_FO";
560 case LANG_FARSI: return "fa_IR";
561 case LANG_FINNISH: return "fi_FI";
562 case LANG_FRENCH:
563 switch (sub)
564 {
565 case SUBLANG_FRENCH: return "fr_FR";
566 case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
567 case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
568 case SUBLANG_FRENCH_SWISS: return "fr_CH";
569 case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
570 case SUBLANG_FRENCH_MONACO: return "fr_MC";
571 }
572 return "fr";
573 case 0x62: /* FRISIAN */ return "fy_NL";
574 case 0x67: /* FULFULDE */ return "ful_NG";
575 case 0x3c: /* GAELIC */
576 switch (sub)
577 {
578 case 0x01: /* SCOTTISH */ return "gd_GB";
579 case 0x02: /* IRISH */ return "ga_IE";
580 }
581 return "C";
582 case LANG_GALICIAN: return "gl_ES";
583 case LANG_GEORGIAN: return "ka_GE";
584 case LANG_GERMAN:
585 switch (sub)
586 {
587 case SUBLANG_GERMAN: return "de_DE";
588 case SUBLANG_GERMAN_SWISS: return "de_CH";
589 case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
590 case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
591 case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
592 }
593 return "de";
594 case LANG_GREEK: return "el_GR";
595 case 0x74: /* GUARANI */ return "gn_PY";
596 case LANG_GUJARATI: return "gu_IN";
597 case 0x68: /* HAUSA */ return "ha_NG";
598 case 0x75: /* HAWAIIAN */
599 /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
600 or Hawaii Creole English ("cpe_US", 600000 speakers)? */
601 return "cpe_US";
602 case LANG_HEBREW: return "he_IL";
603 case LANG_HINDI: return "hi_IN";
604 case LANG_HUNGARIAN: return "hu_HU";
605 case 0x69: /* IBIBIO */ return "nic_NG";
606 case LANG_ICELANDIC: return "is_IS";
607 case 0x70: /* IGBO */ return "ibo_NG";
608 case LANG_INDONESIAN: return "id_ID";
609 case 0x5d: /* INUKTITUT */ return "iu_CA";
610 case LANG_ITALIAN:
611 switch (sub)
612 {
613 case SUBLANG_ITALIAN: return "it_IT";
614 case SUBLANG_ITALIAN_SWISS: return "it_CH";
615 }
616 return "it";
617 case LANG_JAPANESE: return "ja_JP";
618 case LANG_KANNADA: return "kn_IN";
619 case 0x71: /* KANURI */ return "kau_NG";
620 case LANG_KASHMIRI:
621 switch (sub)
622 {
623 case SUBLANG_DEFAULT: return "ks_PK";
624 case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
625 }
626 return "ks";
627 case LANG_KAZAK: return "kk_KZ";
628 case LANG_KONKANI:
629 /* FIXME: Adjust this when such locales appear on Unix. */
630 return "kok_IN";
631 case LANG_KOREAN: return "ko_KR";
632 case LANG_KYRGYZ: return "ky_KG";
633 case 0x54: /* LAO */ return "lo_LA";
634 case 0x76: /* LATIN */ return "la_VA";
635 case LANG_LATVIAN: return "lv_LV";
636 case LANG_LITHUANIAN: return "lt_LT";
637 case LANG_MACEDONIAN: return "mk_MK";
638 case LANG_MALAY:
639 switch (sub)
640 {
641 case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
642 case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
643 }
644 return "ms";
645 case LANG_MALAYALAM: return "ml_IN";
646 case 0x3a: /* MALTESE */ return "mt_MT";
647 case LANG_MANIPURI:
648 /* FIXME: Adjust this when such locales appear on Unix. */
649 return "mni_IN";
650 case LANG_MARATHI: return "mr_IN";
651 case LANG_MONGOLIAN:
652 return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
653 case LANG_NEPALI:
654 switch (sub)
655 {
656 case SUBLANG_DEFAULT: return "ne_NP";
657 case SUBLANG_NEPALI_INDIA: return "ne_IN";
658 }
659 return "ne";
660 case LANG_NORWEGIAN:
661 switch (sub)
662 {
663 case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
664 case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
665 }
666 return "no";
667 case LANG_ORIYA: return "or_IN";
668 case 0x72: /* OROMO */ return "om_ET";
669 case 0x79: /* PAPIAMENTU */ return "pap_AN";
670 case 0x63: /* PASHTO */
671 return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
672 case LANG_POLISH: return "pl_PL";
673 case LANG_PORTUGUESE:
674 switch (sub)
675 {
676 case SUBLANG_PORTUGUESE: return "pt_PT";
677 /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
678 Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
679 case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
680 }
681 return "pt";
682 case LANG_PUNJABI: return "pa_IN";
683 case 0x17: /* RHAETO-ROMANCE */ return "rm_CH";
684 case LANG_ROMANIAN: return "ro_RO";
685 case LANG_RUSSIAN:
686 return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA". */
687 case 0x3b: /* SAMI */ return "se_NO";
688 case LANG_SANSKRIT: return "sa_IN";
689 case LANG_SINDHI: return "sd";
690 case 0x5b: /* SINHALESE */ return "si_LK";
691 case LANG_SLOVAK: return "sk_SK";
692 case LANG_SLOVENIAN: return "sl_SI";
693 case 0x77: /* SOMALI */ return "so_SO";
694 case LANG_SORBIAN:
695 /* FIXME: Adjust this when such locales appear on Unix. */
696 return "wen_DE";
697 case LANG_SPANISH:
698 switch (sub)
699 {
700 case SUBLANG_SPANISH: return "es_ES";
701 case SUBLANG_SPANISH_MEXICAN: return "es_MX";
702 case SUBLANG_SPANISH_MODERN:
703 return "es_ES@modern"; /* not seen on Unix */
704 case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
705 case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
706 case SUBLANG_SPANISH_PANAMA: return "es_PA";
707 case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
708 case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
709 case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
710 case SUBLANG_SPANISH_PERU: return "es_PE";
711 case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
712 case SUBLANG_SPANISH_ECUADOR: return "es_EC";
713 case SUBLANG_SPANISH_CHILE: return "es_CL";
714 case SUBLANG_SPANISH_URUGUAY: return "es_UY";
715 case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
716 case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
717 case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
718 case SUBLANG_SPANISH_HONDURAS: return "es_HN";
719 case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
720 case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
721 }
722 return "es";
723 case 0x30: /* SUTU */ return "bnt_TZ";
724 case LANG_SWAHILI: return "sw_KE";
725 case LANG_SWEDISH:
726 switch (sub)
727 {
728 case SUBLANG_DEFAULT: return "sv_SE";
729 case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
730 }
731 return "sv";
732 case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */
733 case 0x64: /* TAGALOG */ return "tl_PH";
734 case 0x28: /* TAJIK */ return "tg_TJ";
735 case 0x5f: /* TAMAZIGHT */ return "ber_MA";
736 case LANG_TAMIL:
737 return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
738 case LANG_TATAR: return "tt_RU";
739 case LANG_TELUGU: return "te_IN";
740 case LANG_THAI: return "th_TH";
741 case 0x51: /* TIBETAN */ return "bo_CN";
742 case 0x73: /* TIGRINYA */ return "ti_ET";
743 case 0x31: /* TSONGA */ return "ts_ZA";
744 case LANG_TURKISH: return "tr_TR";
745 case 0x42: /* TURKMEN */ return "tk_TM";
746 case LANG_UKRAINIAN: return "uk_UA";
747 case LANG_URDU:
748 switch (sub)
749 {
750 case SUBLANG_URDU_PAKISTAN: return "ur_PK";
751 case SUBLANG_URDU_INDIA: return "ur_IN";
752 }
753 return "ur";
754 case LANG_UZBEK:
755 switch (sub)
756 {
757 /* FIXME: Adjust this when Uzbek locales appear on Unix. */
758 case SUBLANG_UZBEK_LATIN: return "uz_UZ@latin";
759 case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
760 }
761 return "uz";
762 case 0x33: /* VENDA */ return "ven_ZA";
763 case LANG_VIETNAMESE: return "vi_VN";
764 case 0x52: /* WELSH */ return "cy_GB";
765 case 0x34: /* XHOSA */ return "xh_ZA";
766 case 0x78: /* YI */ return "sit_CN";
767 case 0x3d: /* YIDDISH */ return "yi_IL";
768 case 0x6a: /* YORUBA */ return "yo_NG";
769 case 0x35: /* ZULU */ return "zu_ZA";
770 default: return "C";
771 }
772
773#endif
774}