root/trunk/intl/localename.c

Revision 2, 42.2 kB (checked in by jordi, 3 years ago)

Added the initial source layout with autotools and gettext support. Still no code for the project.

Line 
1/* Determine the current selected locale.
2   Copyright (C) 1995-1999, 2000-2005 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/* MacOS X code written by Bruno Haible <bruno@clisp.org>.  */
22
23#ifdef HAVE_CONFIG_H
24# include <config.h>
25#endif
26
27#include <stdlib.h>
28#include <locale.h>
29
30#if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
31# include <string.h>
32# include <CFString.h>
33# if HAVE_CFLOCALECOPYCURRENT
34include <CFLocale.h>
35# elif HAVE_CFPREFERENCESCOPYAPPVALUE
36include <CFPreferences.h>
37# endif
38#endif
39
40#if defined _WIN32 || defined __WIN32__
41# undef WIN32   /* avoid warning on mingw32 */
42# define WIN32
43#endif
44
45#ifdef WIN32
46# define WIN32_LEAN_AND_MEAN
47# include <windows.h>
48/* List of language codes, sorted by value:
49   0x01 LANG_ARABIC
50   0x02 LANG_BULGARIAN
51   0x03 LANG_CATALAN
52   0x04 LANG_CHINESE
53   0x05 LANG_CZECH
54   0x06 LANG_DANISH
55   0x07 LANG_GERMAN
56   0x08 LANG_GREEK
57   0x09 LANG_ENGLISH
58   0x0a LANG_SPANISH
59   0x0b LANG_FINNISH
60   0x0c LANG_FRENCH
61   0x0d LANG_HEBREW
62   0x0e LANG_HUNGARIAN
63   0x0f LANG_ICELANDIC
64   0x10 LANG_ITALIAN
65   0x11 LANG_JAPANESE
66   0x12 LANG_KOREAN
67   0x13 LANG_DUTCH
68   0x14 LANG_NORWEGIAN
69   0x15 LANG_POLISH
70   0x16 LANG_PORTUGUESE
71   0x17 LANG_RHAETO_ROMANCE
72   0x18 LANG_ROMANIAN
73   0x19 LANG_RUSSIAN
74   0x1a LANG_CROATIAN == LANG_SERBIAN
75   0x1b LANG_SLOVAK
76   0x1c LANG_ALBANIAN
77   0x1d LANG_SWEDISH
78   0x1e LANG_THAI
79   0x1f LANG_TURKISH
80   0x20 LANG_URDU
81   0x21 LANG_INDONESIAN
82   0x22 LANG_UKRAINIAN
83   0x23 LANG_BELARUSIAN
84   0x24 LANG_SLOVENIAN
85   0x25 LANG_ESTONIAN
86   0x26 LANG_LATVIAN
87   0x27 LANG_LITHUANIAN
88   0x28 LANG_TAJIK
89   0x29 LANG_FARSI
90   0x2a LANG_VIETNAMESE
91   0x2b LANG_ARMENIAN
92   0x2c LANG_AZERI
93   0x2d LANG_BASQUE
94   0x2e LANG_SORBIAN
95   0x2f LANG_MACEDONIAN
96   0x30 LANG_SUTU
97   0x31 LANG_TSONGA
98   0x32 LANG_TSWANA
99   0x33 LANG_VENDA
100   0x34 LANG_XHOSA
101   0x35 LANG_ZULU
102   0x36 LANG_AFRIKAANS
103   0x37 LANG_GEORGIAN
104   0x38 LANG_FAEROESE
105   0x39 LANG_HINDI
106   0x3a LANG_MALTESE
107   0x3b LANG_SAAMI
108   0x3c LANG_GAELIC
109   0x3d LANG_YIDDISH
110   0x3e LANG_MALAY
111   0x3f LANG_KAZAK
112   0x40 LANG_KYRGYZ
113   0x41 LANG_SWAHILI
114   0x42 LANG_TURKMEN
115   0x43 LANG_UZBEK
116   0x44 LANG_TATAR
117   0x45 LANG_BENGALI
118   0x46 LANG_PUNJABI
119   0x47 LANG_GUJARATI
120   0x48 LANG_ORIYA
121   0x49 LANG_TAMIL
122   0x4a LANG_TELUGU
123   0x4b LANG_KANNADA
124   0x4c LANG_MALAYALAM
125   0x4d LANG_ASSAMESE
126   0x4e LANG_MARATHI
127   0x4f LANG_SANSKRIT
128   0x50 LANG_MONGOLIAN
129   0x51 LANG_TIBETAN
130   0x52 LANG_WELSH
131   0x53 LANG_CAMBODIAN
132   0x54 LANG_LAO
133   0x55 LANG_BURMESE
134   0x56 LANG_GALICIAN
135   0x57 LANG_KONKANI
136   0x58 LANG_MANIPURI
137   0x59 LANG_SINDHI
138   0x5a LANG_SYRIAC
139   0x5b LANG_SINHALESE
140   0x5c LANG_CHEROKEE
141   0x5d LANG_INUKTITUT
142   0x5e LANG_AMHARIC
143   0x5f LANG_TAMAZIGHT
144   0x60 LANG_KASHMIRI
145   0x61 LANG_NEPALI
146   0x62 LANG_FRISIAN
147   0x63 LANG_PASHTO
148   0x64 LANG_TAGALOG
149   0x65 LANG_DIVEHI
150   0x66 LANG_EDO
151   0x67 LANG_FULFULDE
152   0x68 LANG_HAUSA
153   0x69 LANG_IBIBIO
154   0x6a LANG_YORUBA
155   0x70 LANG_IGBO
156   0x71 LANG_KANURI
157   0x72 LANG_OROMO
158   0x73 LANG_TIGRINYA
159   0x74 LANG_GUARANI
160   0x75 LANG_HAWAIIAN
161   0x76 LANG_LATIN
162   0x77 LANG_SOMALI
163   0x78 LANG_YI
164   0x79 LANG_PAPIAMENTU
165*/
166/* Mingw headers don't have latest language and sublanguage codes.  */
167# ifndef LANG_AFRIKAANS
168# define LANG_AFRIKAANS 0x36
169# endif
170# ifndef LANG_ALBANIAN
171# define LANG_ALBANIAN 0x1c
172# endif
173# ifndef LANG_AMHARIC
174# define LANG_AMHARIC 0x5e
175# endif
176# ifndef LANG_ARABIC
177# define LANG_ARABIC 0x01
178# endif
179# ifndef LANG_ARMENIAN
180# define LANG_ARMENIAN 0x2b
181# endif
182# ifndef LANG_ASSAMESE
183# define LANG_ASSAMESE 0x4d
184# endif
185# ifndef LANG_AZERI
186# define LANG_AZERI 0x2c
187# endif
188# ifndef LANG_BASQUE
189# define LANG_BASQUE 0x2d
190# endif
191# ifndef LANG_BELARUSIAN
192# define LANG_BELARUSIAN 0x23
193# endif
194# ifndef LANG_BENGALI
195# define LANG_BENGALI 0x45
196# endif
197# ifndef LANG_BURMESE
198# define LANG_BURMESE 0x55
199# endif
200# ifndef LANG_CAMBODIAN
201# define LANG_CAMBODIAN 0x53
202# endif
203# ifndef LANG_CATALAN
204# define LANG_CATALAN 0x03
205# endif
206# ifndef LANG_CHEROKEE
207# define LANG_CHEROKEE 0x5c
208# endif
209# ifndef LANG_DIVEHI
210# define LANG_DIVEHI 0x65
211# endif
212# ifndef LANG_EDO
213# define LANG_EDO 0x66
214# endif
215# ifndef LANG_ESTONIAN
216# define LANG_ESTONIAN 0x25
217# endif
218# ifndef LANG_FAEROESE
219# define LANG_FAEROESE 0x38
220# endif
221# ifndef LANG_FARSI
222# define LANG_FARSI 0x29
223# endif
224# ifndef LANG_FRISIAN
225# define LANG_FRISIAN 0x62
226# endif
227# ifndef LANG_FULFULDE
228# define LANG_FULFULDE 0x67
229# endif
230# ifndef LANG_GAELIC
231# define LANG_GAELIC 0x3c
232# endif
233# ifndef LANG_GALICIAN
234# define LANG_GALICIAN 0x56
235# endif
236# ifndef LANG_GEORGIAN
237# define LANG_GEORGIAN 0x37
238# endif
239# ifndef LANG_GUARANI
240# define LANG_GUARANI 0x74
241# endif
242# ifndef LANG_GUJARATI
243# define LANG_GUJARATI 0x47
244# endif
245# ifndef LANG_HAUSA
246# define LANG_HAUSA 0x68
247# endif
248# ifndef LANG_HAWAIIAN
249# define LANG_HAWAIIAN 0x75
250# endif
251# ifndef LANG_HEBREW
252# define LANG_HEBREW 0x0d
253# endif
254# ifndef LANG_HINDI
255# define LANG_HINDI 0x39
256# endif
257# ifndef LANG_IBIBIO
258# define LANG_IBIBIO 0x69
259# endif
260# ifndef LANG_IGBO
261# define LANG_IGBO 0x70
262# endif
263# ifndef LANG_INDONESIAN
264# define LANG_INDONESIAN 0x21
265# endif
266# ifndef LANG_INUKTITUT
267# define LANG_INUKTITUT 0x5d
268# endif
269# ifndef LANG_KANNADA
270# define LANG_KANNADA 0x4b
271# endif
272# ifndef LANG_KANURI
273# define LANG_KANURI 0x71
274# endif
275# ifndef LANG_KASHMIRI
276# define LANG_KASHMIRI 0x60
277# endif
278# ifndef LANG_KAZAK
279# define LANG_KAZAK 0x3f
280# endif
281# ifndef LANG_KONKANI
282# define LANG_KONKANI 0x57
283# endif
284# ifndef LANG_KYRGYZ
285# define LANG_KYRGYZ 0x40
286# endif
287# ifndef LANG_LAO
288# define LANG_LAO 0x54
289# endif
290# ifndef LANG_LATIN
291# define LANG_LATIN 0x76
292# endif
293# ifndef LANG_LATVIAN
294# define LANG_LATVIAN 0x26
295# endif
296# ifndef LANG_LITHUANIAN
297# define LANG_LITHUANIAN 0x27
298# endif
299# ifndef LANG_MACEDONIAN
300# define LANG_MACEDONIAN 0x2f
301# endif
302# ifndef LANG_MALAY
303# define LANG_MALAY 0x3e
304# endif
305# ifndef LANG_MALAYALAM
306# define LANG_MALAYALAM 0x4c
307# endif
308# ifndef LANG_MALTESE
309# define LANG_MALTESE 0x3a
310# endif
311# ifndef LANG_MANIPURI
312# define LANG_MANIPURI 0x58
313# endif
314# ifndef LANG_MARATHI
315# define LANG_MARATHI 0x4e
316# endif
317# ifndef LANG_MONGOLIAN
318# define LANG_MONGOLIAN 0x50
319# endif
320# ifndef LANG_NEPALI
321# define LANG_NEPALI 0x61
322# endif
323# ifndef LANG_ORIYA
324# define LANG_ORIYA 0x48
325# endif
326# ifndef LANG_OROMO
327# define LANG_OROMO 0x72
328# endif
329# ifndef LANG_PAPIAMENTU
330# define LANG_PAPIAMENTU 0x79
331# endif
332# ifndef LANG_PASHTO
333# define LANG_PASHTO 0x63
334# endif
335# ifndef LANG_PUNJABI
336# define LANG_PUNJABI 0x46
337# endif
338# ifndef LANG_RHAETO_ROMANCE
339# define LANG_RHAETO_ROMANCE 0x17
340# endif
341# ifndef LANG_SAAMI
342# define LANG_SAAMI 0x3b
343# endif
344# ifndef LANG_SANSKRIT
345# define LANG_SANSKRIT 0x4f
346# endif
347# ifndef LANG_SERBIAN
348# define LANG_SERBIAN 0x1a
349# endif
350# ifndef LANG_SINDHI
351# define LANG_SINDHI 0x59
352# endif
353# ifndef LANG_SINHALESE
354# define LANG_SINHALESE 0x5b
355# endif
356# ifndef LANG_SLOVAK
357# define LANG_SLOVAK 0x1b
358# endif
359# ifndef LANG_SOMALI
360# define LANG_SOMALI 0x77
361# endif
362# ifndef LANG_SORBIAN
363# define LANG_SORBIAN 0x2e
364# endif
365# ifndef LANG_SUTU
366# define LANG_SUTU 0x30
367# endif
368# ifndef LANG_SWAHILI
369# define LANG_SWAHILI 0x41
370# endif
371# ifndef LANG_SYRIAC
372# define LANG_SYRIAC 0x5a
373# endif
374# ifndef LANG_TAGALOG
375# define LANG_TAGALOG 0x64
376# endif
377# ifndef LANG_TAJIK
378# define LANG_TAJIK 0x28
379# endif
380# ifndef LANG_TAMAZIGHT
381# define LANG_TAMAZIGHT 0x5f
382# endif
383# ifndef LANG_TAMIL
384# define LANG_TAMIL 0x49
385# endif
386# ifndef LANG_TATAR
387# define LANG_TATAR 0x44
388# endif
389# ifndef LANG_TELUGU
390# define LANG_TELUGU 0x4a
391# endif
392# ifndef LANG_THAI
393# define LANG_THAI 0x1e
394# endif
395# ifndef LANG_TIBETAN
396# define LANG_TIBETAN 0x51
397# endif
398# ifndef LANG_TIGRINYA
399# define LANG_TIGRINYA 0x73
400# endif
401# ifndef LANG_TSONGA
402# define LANG_TSONGA 0x31
403# endif
404# ifndef LANG_TSWANA
405# define LANG_TSWANA 0x32
406# endif
407# ifndef LANG_TURKMEN
408# define LANG_TURKMEN 0x42
409# endif
410# ifndef LANG_UKRAINIAN
411# define LANG_UKRAINIAN 0x22
412# endif
413# ifndef LANG_URDU
414# define LANG_URDU 0x20
415# endif
416# ifndef LANG_UZBEK
417# define LANG_UZBEK 0x43
418# endif
419# ifndef LANG_VENDA
420# define LANG_VENDA 0x33
421# endif
422# ifndef LANG_VIETNAMESE
423# define LANG_VIETNAMESE 0x2a
424# endif
425# ifndef LANG_WELSH
426# define LANG_WELSH 0x52
427# endif
428# ifndef LANG_XHOSA
429# define LANG_XHOSA 0x34
430# endif
431# ifndef LANG_YI
432# define LANG_YI 0x78
433# endif
434# ifndef LANG_YIDDISH
435# define LANG_YIDDISH 0x3d
436# endif
437# ifndef LANG_YORUBA
438# define LANG_YORUBA 0x6a
439# endif
440# ifndef LANG_ZULU
441# define LANG_ZULU 0x35
442# endif
443# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
444# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
445# endif
446# ifndef SUBLANG_ARABIC_IRAQ
447# define SUBLANG_ARABIC_IRAQ 0x02
448# endif
449# ifndef SUBLANG_ARABIC_EGYPT
450# define SUBLANG_ARABIC_EGYPT 0x03
451# endif
452# ifndef SUBLANG_ARABIC_LIBYA
453# define SUBLANG_ARABIC_LIBYA 0x04
454# endif
455# ifndef SUBLANG_ARABIC_ALGERIA
456# define SUBLANG_ARABIC_ALGERIA 0x05
457# endif
458# ifndef SUBLANG_ARABIC_MOROCCO
459# define SUBLANG_ARABIC_MOROCCO 0x06
460# endif
461# ifndef SUBLANG_ARABIC_TUNISIA
462# define SUBLANG_ARABIC_TUNISIA 0x07
463# endif
464# ifndef SUBLANG_ARABIC_OMAN
465# define SUBLANG_ARABIC_OMAN 0x08
466# endif
467# ifndef SUBLANG_ARABIC_YEMEN
468# define SUBLANG_ARABIC_YEMEN 0x09
469# endif
470# ifndef SUBLANG_ARABIC_SYRIA
471# define SUBLANG_ARABIC_SYRIA 0x0a
472# endif
473# ifndef SUBLANG_ARABIC_JORDAN
474# define SUBLANG_ARABIC_JORDAN 0x0b
475# endif
476# ifndef SUBLANG_ARABIC_LEBANON
477# define SUBLANG_ARABIC_LEBANON 0x0c
478# endif
479# ifndef SUBLANG_ARABIC_KUWAIT
480# define SUBLANG_ARABIC_KUWAIT 0x0d
481# endif
482# ifndef SUBLANG_ARABIC_UAE
483# define SUBLANG_ARABIC_UAE 0x0e
484# endif
485# ifndef SUBLANG_ARABIC_BAHRAIN
486# define SUBLANG_ARABIC_BAHRAIN 0x0f
487# endif
488# ifndef SUBLANG_ARABIC_QATAR
489# define SUBLANG_ARABIC_QATAR 0x10
490# endif
491# ifndef SUBLANG_AZERI_LATIN
492# define SUBLANG_AZERI_LATIN 0x01
493# endif
494# ifndef SUBLANG_AZERI_CYRILLIC
495# define SUBLANG_AZERI_CYRILLIC 0x02
496# endif
497# ifndef SUBLANG_BENGALI_INDIA
498# define SUBLANG_BENGALI_INDIA 0x00
499# endif
500# ifndef SUBLANG_BENGALI_BANGLADESH
501# define SUBLANG_BENGALI_BANGLADESH 0x01
502# endif
503# ifndef SUBLANG_CHINESE_MACAU
504# define SUBLANG_CHINESE_MACAU 0x05
505# endif
506# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
507# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
508# endif
509# ifndef SUBLANG_ENGLISH_JAMAICA
510# define SUBLANG_ENGLISH_JAMAICA 0x08
511# endif
512# ifndef SUBLANG_ENGLISH_CARIBBEAN
513# define SUBLANG_ENGLISH_CARIBBEAN 0x09
514# endif
515# ifndef SUBLANG_ENGLISH_BELIZE
516# define SUBLANG_ENGLISH_BELIZE 0x0a
517# endif
518# ifndef SUBLANG_ENGLISH_TRINIDAD
519# define SUBLANG_ENGLISH_TRINIDAD 0x0b
520# endif
521# ifndef SUBLANG_ENGLISH_ZIMBABWE
522# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
523# endif
524# ifndef SUBLANG_ENGLISH_PHILIPPINES
525# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
526# endif
527# ifndef SUBLANG_ENGLISH_INDONESIA
528# define SUBLANG_ENGLISH_INDONESIA 0x0e
529# endif
530# ifndef SUBLANG_ENGLISH_HONGKONG
531# define SUBLANG_ENGLISH_HONGKONG 0x0f
532# endif
533# ifndef SUBLANG_ENGLISH_INDIA
534# define SUBLANG_ENGLISH_INDIA 0x10
535# endif
536# ifndef SUBLANG_ENGLISH_MALAYSIA
537# define SUBLANG_ENGLISH_MALAYSIA 0x11
538# endif
539# ifndef SUBLANG_ENGLISH_SINGAPORE
540# define SUBLANG_ENGLISH_SINGAPORE 0x12
541# endif
542# ifndef SUBLANG_FRENCH_LUXEMBOURG
543# define SUBLANG_FRENCH_LUXEMBOURG 0x05
544# endif
545# ifndef SUBLANG_FRENCH_MONACO
546# define SUBLANG_FRENCH_MONACO 0x06
547# endif
548# ifndef SUBLANG_FRENCH_WESTINDIES
549# define SUBLANG_FRENCH_WESTINDIES 0x07
550# endif
551# ifndef SUBLANG_FRENCH_REUNION
552# define SUBLANG_FRENCH_REUNION 0x08
553# endif
554# ifndef SUBLANG_FRENCH_CONGO
555# define SUBLANG_FRENCH_CONGO 0x09
556# endif
557# ifndef SUBLANG_FRENCH_SENEGAL
558# define SUBLANG_FRENCH_SENEGAL 0x0a
559# endif
560# ifndef SUBLANG_FRENCH_CAMEROON
561# define SUBLANG_FRENCH_CAMEROON 0x0b
562# endif
563# ifndef SUBLANG_FRENCH_COTEDIVOIRE
564# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
565# endif
566# ifndef SUBLANG_FRENCH_MALI
567# define SUBLANG_FRENCH_MALI 0x0d
568# endif
569# ifndef SUBLANG_FRENCH_MOROCCO
570# define SUBLANG_FRENCH_MOROCCO 0x0e
571# endif
572# ifndef SUBLANG_FRENCH_HAITI
573# define SUBLANG_FRENCH_HAITI 0x0f
574# endif
575# ifndef SUBLANG_GERMAN_LUXEMBOURG
576# define SUBLANG_GERMAN_LUXEMBOURG 0x04
577# endif
578# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
579# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
580# endif
581# ifndef SUBLANG_KASHMIRI_INDIA
582# define SUBLANG_KASHMIRI_INDIA 0x02
583# endif
584# ifndef SUBLANG_MALAY_MALAYSIA
585# define SUBLANG_MALAY_MALAYSIA 0x01
586# endif
587# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
588# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
589# endif
590# ifndef SUBLANG_NEPALI_INDIA
591# define SUBLANG_NEPALI_INDIA 0x02
592# endif
593# ifndef SUBLANG_PUNJABI_INDIA
594# define SUBLANG_PUNJABI_INDIA 0x00
595# endif
596# ifndef SUBLANG_PUNJABI_PAKISTAN
597# define SUBLANG_PUNJABI_PAKISTAN 0x01
598# endif
599# ifndef SUBLANG_ROMANIAN_ROMANIA
600# define SUBLANG_ROMANIAN_ROMANIA 0x00
601# endif
602# ifndef SUBLANG_ROMANIAN_MOLDOVA
603# define SUBLANG_ROMANIAN_MOLDOVA 0x01
604# endif
605# ifndef SUBLANG_SERBIAN_LATIN
606# define SUBLANG_SERBIAN_LATIN 0x02
607# endif
608# ifndef SUBLANG_SERBIAN_CYRILLIC
609# define SUBLANG_SERBIAN_CYRILLIC 0x03
610# endif
611# ifndef SUBLANG_SINDHI_INDIA
612# define SUBLANG_SINDHI_INDIA 0x00
613# endif
614# ifndef SUBLANG_SINDHI_PAKISTAN
615# define SUBLANG_SINDHI_PAKISTAN 0x01
616# endif
617# ifndef SUBLANG_SPANISH_GUATEMALA
618# define SUBLANG_SPANISH_GUATEMALA 0x04
619# endif
620# ifndef SUBLANG_SPANISH_COSTA_RICA
621# define SUBLANG_SPANISH_COSTA_RICA 0x05
622# endif
623# ifndef SUBLANG_SPANISH_PANAMA
624# define SUBLANG_SPANISH_PANAMA 0x06
625# endif
626# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
627# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
628# endif
629# ifndef SUBLANG_SPANISH_VENEZUELA
630# define SUBLANG_SPANISH_VENEZUELA 0x08
631# endif
632# ifndef SUBLANG_SPANISH_COLOMBIA
633# define SUBLANG_SPANISH_COLOMBIA 0x09
634# endif
635# ifndef SUBLANG_SPANISH_PERU
636# define SUBLANG_SPANISH_PERU 0x0a
637# endif
638# ifndef SUBLANG_SPANISH_ARGENTINA
639# define SUBLANG_SPANISH_ARGENTINA 0x0b
640# endif
641# ifndef SUBLANG_SPANISH_ECUADOR
642# define SUBLANG_SPANISH_ECUADOR 0x0c
643# endif
644# ifndef SUBLANG_SPANISH_CHILE
645# define SUBLANG_SPANISH_CHILE 0x0d
646# endif
647# ifndef SUBLANG_SPANISH_URUGUAY
648# define SUBLANG_SPANISH_URUGUAY 0x0e
649# endif
650# ifndef SUBLANG_SPANISH_PARAGUAY
651# define SUBLANG_SPANISH_PARAGUAY 0x0f
652# endif
653# ifndef SUBLANG_SPANISH_BOLIVIA
654# define SUBLANG_SPANISH_BOLIVIA 0x10
655# endif
656# ifndef SUBLANG_SPANISH_EL_SALVADOR
657# define SUBLANG_SPANISH_EL_SALVADOR 0x11
658# endif
659# ifndef SUBLANG_SPANISH_HONDURAS
660# define SUBLANG_SPANISH_HONDURAS 0x12
661# endif
662# ifndef SUBLANG_SPANISH_NICARAGUA
663# define SUBLANG_SPANISH_NICARAGUA 0x13
664# endif
665# ifndef SUBLANG_SPANISH_PUERTO_RICO
666# define SUBLANG_SPANISH_PUERTO_RICO 0x14
667# endif
668# ifndef SUBLANG_SWEDISH_FINLAND
669# define SUBLANG_SWEDISH_FINLAND 0x02
670# endif
671# ifndef SUBLANG_TAMAZIGHT_ARABIC
672# define SUBLANG_TAMAZIGHT_ARABIC 0x01
673# endif
674# ifndef SUBLANG_TAMAZIGHT_LATIN
675# define SUBLANG_TAMAZIGHT_LATIN 0x02
676# endif
677# ifndef SUBLANG_TIGRINYA_ETHIOPIA
678# define SUBLANG_TIGRINYA_ETHIOPIA 0x00
679# endif
680# ifndef SUBLANG_TIGRINYA_ERITREA
681# define SUBLANG_TIGRINYA_ERITREA 0x01
682# endif
683# ifndef SUBLANG_URDU_PAKISTAN
684# define SUBLANG_URDU_PAKISTAN 0x01
685# endif
686# ifndef SUBLANG_URDU_INDIA
687# define SUBLANG_URDU_INDIA 0x02
688# endif
689# ifndef SUBLANG_UZBEK_LATIN
690# define SUBLANG_UZBEK_LATIN 0x01
691# endif
692# ifndef SUBLANG_UZBEK_CYRILLIC
693# define SUBLANG_UZBEK_CYRILLIC 0x02
694# endif
695#endif
696
697# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
698/* MacOS X 10.2 or newer */
699
700/* Canonicalize a MacOS X locale name to a Unix locale name.
701   NAME is a sufficiently large buffer.
702   On input, it contains the MacOS X locale name.
703   On output, it contains the Unix locale name.  */
704void
705_nl_locale_name_canonicalize (char *name)
706{
707  /* This conversion is based on a posting by
708     Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08,
709     http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
710
711  /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
712     ISO 3166) names.  Prior to MacOS X 10.3, there is no API for doing this.
713     Therefore we do it ourselves, using a table based on the results of the
714     MacOS X 10.3.8 function
715     CFLocaleCreateCanonicalLocaleIdentifierFromString().  */
716  typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
717      legacy_entry;
718  static const legacy_entry legacy_table[] = {
719    { "Afrikaans",             "af" },
720    { "Albanian",              "sq" },
721    { "Amharic",               "am" },
722    { "Arabic",                "ar" },
723    { "Armenian",              "hy" },
724    { "Assamese",              "as" },
725    { "Aymara",                "ay" },
726    { "Azerbaijani",           "az" },
727    { "Basque",                "eu" },
728    { "Belarusian",            "be" },
729    { "Belorussian",           "be" },
730    { "Bengali",               "bn" },
731    { "Brazilian Portugese",   "pt_BR" },
732    { "Brazilian Portuguese""pt_BR" },
733    { "Breton",                "br" },
734    { "Bulgarian",             "bg" },
735    { "Burmese",               "my" },
736    { "Byelorussian",          "be" },
737    { "Catalan",               "ca" },
738    { "Chewa",                 "ny" },
739    { "Chichewa",              "ny" },
740    { "Chinese",               "zh" },
741    { "Chinese, Simplified",   "zh_CN" },
742    { "Chinese, Traditional""zh_TW" },
743    { "Chinese, Tradtional",   "zh_TW" },
744    { "Croatian",              "hr" },
745    { "Czech",                 "cs" },
746    { "Danish",                "da" },
747    { "Dutch",                 "nl" },
748    { "Dzongkha",              "dz" },
749    { "English",               "en" },
750    { "Esperanto",             "eo" },
751    { "Estonian",              "et" },
752    { "Faroese",               "fo" },
753    { "Farsi",                 "fa" },
754    { "Finnish",               "fi" },
755    { "Flemish",               "nl_BE" },
756    { "French",                "fr" },
757    { "Galician",              "gl" },
758    { "Gallegan",              "gl" },
759    { "Georgian",              "ka" },
760    { "German",                "de" },
761    { "Greek",                 "el" },
762    { "Greenlandic",           "kl" },
763    { "Guarani",               "gn" },
764    { "Gujarati",              "gu" },
765    { "Hawaiian",              "haw" }, /* Yes, "haw", not "cpe".  */
766    { "Hebrew",                "he" },
767    { "Hindi",                 "hi" },
768    { "Hungarian",             "hu" },
769    { "Icelandic",             "is" },
770    { "Indonesian",            "id" },
771    { "Inuktitut",             "iu" },
772    { "Irish",                 "ga" },
773    { "Italian",               "it" },
774    { "Japanese",              "ja" },
775    { "Javanese",              "jv" },
776    { "Kalaallisut",           "kl" },
777    { "Kannada",               "kn" },
778    { "Kashmiri",              "ks" },
779    { "Kazakh",                "kk" },
780    { "Khmer",                 "km" },
781    { "Kinyarwanda",           "rw" },
782    { "Kirghiz",               "ky" },
783    { "Korean",                "ko" },
784    { "Kurdish",               "ku" },
785    { "Latin",                 "la" },
786    { "Latvian",               "lv" },
787    { "Lithuanian",            "lt" },
788    { "Macedonian",            "mk" },
789    { "Malagasy",              "mg" },
790    { "Malay",                 "ms" },
791    { "Malayalam",             "ml" },
792    { "Maltese",               "mt" },
793    { "Manx",                  "gv" },
794    { "Marathi",               "mr" },
795    { "Moldavian",             "mo" },
796    { "Mongolian",             "mn" },
797    { "Nepali",                "ne" },
798    { "Norwegian",             "nb" }, /* Yes, "nb", not the obsolete "no".  */
799    { "Nyanja",                "ny" },
800    { "Nynorsk",               "nn" },
801    { "Oriya",                 "or" },
802    { "Oromo",                 "om" },
803    { "Panjabi",               "pa" },
804    { "Pashto",                "ps" },
805    { "Persian",               "fa" },
806    { "Polish",                "pl" },
807    { "Portuguese",            "pt" },
808    { "Portuguese, Brazilian", "pt_BR" },
809    { "Punjabi",               "pa" },
810    { "Pushto",                "ps" },
811    { "Quechua",               "qu" },
812    { "Romanian",              "ro" },
813    { "Ruanda",                "rw" },
814    { "Rundi",                 "rn" },
815    { "Russian",               "ru" },
816    { "Sami",                  "se_NO" }, /* Not just "se".  */
817    { "Sanskrit",              "sa" },
818    { "Scottish",              "gd" },
819    { "Serbian",               "sr" },
820    { "Simplified Chinese",    "zh_CN" },
821    { "Sindhi",                "sd" },
822    { "Sinhalese",             "si" },
823    { "Slovak",                "sk" },
824    { "Slovenian",             "sl" },
825    { "Somali",                "so" },
826    { "Spanish",               "es" },
827    { "Sundanese",             "su" },
828    { "Swahili",               "sw" },
829    { "Swedish",               "sv" },
830    { "Tagalog",               "tl" },
831    { "Tajik",                 "tg" },
832    { "Tajiki",                "tg" },
833    { "Tamil",                 "ta" },
834    { "Tatar",                 "tt" },
835    { "Telugu",                "te" },
836    { "Thai",                  "th" },
837    { "Tibetan",               "bo" },
838    { "Tigrinya",              "ti" },
839    { "Tongan",                "to" },
840    { "Traditional Chinese",   "zh_TW" },