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