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