]> git.sesse.net Git - vlc/blob - src/misc/iso_lang.c
*Move function that translates language codes into country name in src/misc
[vlc] / src / misc / iso_lang.c
1 /*****************************************************************************
2  * iso_lang.c: function to decode language code (in dvd or a52 for instance).
3  *****************************************************************************
4  * Copyright (C) 1998-2001 VideoLAN
5  * $Id: iso_lang.c,v 1.1 2001/11/07 17:37:16 stef Exp $
6  *
7  * Author: Stéphane Borel <stef@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "defs.h"
28
29 #include <stdio.h>
30
31 #include "config.h"
32 #include "common.h"
33
34 /*****************************************************************************
35  * Local tables
36  *****************************************************************************/
37 static struct
38 {
39     char    p_code[3];
40     char    p_lang_long[20];
41 }
42
43 lang_tbl[] =
44 {
45     /* The ISO 639 language codes.
46      * Language names with * prefix are not spelled in their own language 
47      */
48     { "  ", "Not Specified" },
49     { "aa", "*Afar" },
50     { "ab", "*Abkhazian" },
51     { "af", "*Afrikaans" },
52     { "am", "*Amharic" },
53     { "ar", "*Arabic" },
54     { "as", "*Assamese" },
55     { "ay", "*Aymara" },
56     { "az", "*Azerbaijani" },
57     { "ba", "*Bashkir" },
58     { "be", "*Byelorussian" },
59     { "bg", "*Bulgarian" },
60     { "bh", "*Bihari" },
61     { "bi", "*Bislama" },
62     { "bn", "*Bengali; Bangla" },
63     { "bo", "*Tibetan" },
64     { "br", "*Breton" },
65     { "ca", "*Catalan" },
66     { "co", "*Corsican" },
67     { "cs", "*Czech(Ceske)" },
68     { "cy", "*Welsh" },
69     { "da", "Dansk" },
70     { "de", "Deutsch" },
71     { "dz", "*Bhutani" },
72     { "el", "*Greek" },
73     { "en", "English" },
74     { "eo", "*Esperanto" },
75     { "es", "Espanol" },
76     { "et", "*Estonian" },
77     { "eu", "*Basque" },
78     { "fa", "*Persian" },
79     { "fi", "Suomi" },
80     { "fj", "*Fiji" },
81     { "fo", "*Faroese" },
82     { "fr", "Francais" },
83     { "fy", "*Frisian" },
84     { "ga", "*Irish" },
85     { "gd", "*Scots Gaelic" },
86     { "gl", "*Galician" },
87     { "gn", "*Guarani" },
88     { "gu", "*Gujarati" },
89     { "ha", "*Hausa" },
90     { "he", "*Hebrew" },                                      /* formerly iw */
91     { "hi", "*Hindi" },
92     { "hr", "Hrvatski" },                                        /* Croatian */
93     { "hu", "Magyar" },
94     { "hy", "*Armenian" },
95     { "ia", "*Interlingua" },
96     { "id", "*Indonesian" },                                  /* formerly in */
97     { "ie", "*Interlingue" },
98     { "ik", "*Inupiak" },
99     { "in", "*Indonesian" },                               /* replaced by id */
100     { "is", "Islenska" },
101     { "it", "Italiano" },
102     { "iu", "*Inuktitut" },
103     { "iw", "*Hebrew" },                                   /* replaced by he */
104     { "ja", "*Japanese" },
105     { "ji", "*Yiddish" },                                  /* replaced by yi */
106     { "jw", "*Javanese" },
107     { "ka", "*Georgian" },
108     { "kk", "*Kazakh" },
109     { "kl", "*Greenlandic" },
110     { "km", "*Cambodian" },
111     { "kn", "*Kannada" },
112     { "ko", "*Korean" },
113     { "ks", "*Kashmiri" },
114     { "ku", "*Kurdish" },
115     { "ky", "*Kirghiz" },
116     { "la", "*Latin" },
117     { "ln", "*Lingala" },
118     { "lo", "*Laothian" },
119     { "lt", "*Lithuanian" },
120     { "lv", "*Latvian, Lettish" },
121     { "mg", "*Malagasy" },
122     { "mi", "*Maori" },
123     { "mk", "*Macedonian" },
124     { "ml", "*Malayalam" },
125     { "mn", "*Mongolian" },
126     { "mo", "*Moldavian" },
127     { "mr", "*Marathi" },
128     { "ms", "*Malay" },
129     { "mt", "*Maltese" },
130     { "my", "*Burmese" },
131     { "na", "*Nauru" },
132     { "ne", "*Nepali" },
133     { "nl", "Nederlands" },
134     { "no", "Norsk" },
135     { "oc", "*Occitan" },
136     { "om", "*(Afan) Oromo" },
137     { "or", "*Oriya" },
138     { "pa", "*Punjabi" },
139     { "pl", "*Polish" },
140     { "ps", "*Pashto, Pushto" },
141     { "pt", "Portugues" },
142     { "qu", "*Quechua" },
143     { "rm", "*Rhaeto-Romance" },
144     { "rn", "*Kirundi" },
145     { "ro", "*Romanian"  },
146     { "ru", "*Russian" },
147     { "rw", "*Kinyarwanda" },
148     { "sa", "*Sanskrit" },
149     { "sd", "*Sindhi" },
150     { "sg", "*Sangho" },
151     { "sh", "*Serbo-Croatian" },
152     { "si", "*Sinhalese" },
153     { "sk", "*Slovak" },
154     { "sl", "*Slovenian" },
155     { "sm", "*Samoan" },
156     { "sn", "*Shona"  },
157     { "so", "*Somali" },
158     { "sq", "*Albanian" },
159     { "sr", "*Serbian" },
160     { "ss", "*Siswati" },
161     { "st", "*Sesotho" },
162     { "su", "*Sundanese" },
163     { "sv", "Svenska" },
164     { "sw", "*Swahili" },
165     { "ta", "*Tamil" },
166     { "te", "*Telugu" },
167     { "tg", "*Tajik" },
168     { "th", "*Thai" },
169     { "ti", "*Tigrinya" },
170     { "tk", "*Turkmen" },
171     { "tl", "*Tagalog" },
172     { "tn", "*Setswana" },
173     { "to", "*Tonga" },
174     { "tr", "*Turkish" },
175     { "ts", "*Tsonga" },
176     { "tt", "*Tatar" },
177     { "tw", "*Twi" },
178     { "ug", "*Uighur" },
179     { "uk", "*Ukrainian" },
180     { "ur", "*Urdu" },
181     { "uz", "*Uzbek" },
182     { "vi", "*Vietnamese" },
183     { "vo", "*Volapuk" },
184     { "wo", "*Wolof" },
185     { "xh", "*Xhosa" },
186     { "yi", "*Yiddish" },                                     /* formerly ji */
187     { "yo", "*Yoruba" },
188     { "za", "*Zhuang" },
189     { "zh", "*Chinese" },
190     { "zu", "*Zulu" },
191     { "\0", "" }
192 };
193
194 /*****************************************************************************
195  * DecodeLanguage: gives the long language name from the two-letters
196  *                 ISO-639 code
197  *****************************************************************************/
198 char * DecodeLanguage( u16 i_code )
199 {
200     int     i = 0;
201
202     while( memcmp( lang_tbl[i].p_code, &i_code, 2 ) &&
203            lang_tbl[i].p_lang_long[0] )
204     {
205         i++;
206     }
207
208     return lang_tbl[i].p_lang_long;
209 }
210