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