/*****************************************************************************
* iso_lang.c: function to decode language code (in dvd or a52 for instance).
*****************************************************************************
- * Copyright (C) 1998-2001 VideoLAN
- * $Id: iso_lang.c,v 1.2 2001/12/09 17:01:37 sam Exp $
+ * Copyright (C) 1998-2004 the VideoLAN team
+ * $Id$
*
- * Author: Stéphane Borel <stef@via.ecp.fr>
+ * Author: Stéphane Borel <stef@via.ecp.fr>
+ * Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
-
#include <stdio.h>
-#include "common.h"
+#include <vlc/vlc.h>
+
+#include "iso_lang.h"
/*****************************************************************************
* Local tables
*****************************************************************************/
-static struct
-{
- char p_code[3];
- char p_lang_long[20];
-}
+#include "iso-639_def.h"
-lang_tbl[] =
-{
- /* The ISO 639 language codes.
- * Language names with * prefix are not spelled in their own language
- */
- { " ", "Not Specified" },
- { "aa", "*Afar" },
- { "ab", "*Abkhazian" },
- { "af", "*Afrikaans" },
- { "am", "*Amharic" },
- { "ar", "*Arabic" },
- { "as", "*Assamese" },
- { "ay", "*Aymara" },
- { "az", "*Azerbaijani" },
- { "ba", "*Bashkir" },
- { "be", "*Byelorussian" },
- { "bg", "*Bulgarian" },
- { "bh", "*Bihari" },
- { "bi", "*Bislama" },
- { "bn", "*Bengali; Bangla" },
- { "bo", "*Tibetan" },
- { "br", "*Breton" },
- { "ca", "*Catalan" },
- { "co", "*Corsican" },
- { "cs", "*Czech(Ceske)" },
- { "cy", "*Welsh" },
- { "da", "Dansk" },
- { "de", "Deutsch" },
- { "dz", "*Bhutani" },
- { "el", "*Greek" },
- { "en", "English" },
- { "eo", "*Esperanto" },
- { "es", "Espanol" },
- { "et", "*Estonian" },
- { "eu", "*Basque" },
- { "fa", "*Persian" },
- { "fi", "Suomi" },
- { "fj", "*Fiji" },
- { "fo", "*Faroese" },
- { "fr", "Francais" },
- { "fy", "*Frisian" },
- { "ga", "*Irish" },
- { "gd", "*Scots Gaelic" },
- { "gl", "*Galician" },
- { "gn", "*Guarani" },
- { "gu", "*Gujarati" },
- { "ha", "*Hausa" },
- { "he", "*Hebrew" }, /* formerly iw */
- { "hi", "*Hindi" },
- { "hr", "Hrvatski" }, /* Croatian */
- { "hu", "Magyar" },
- { "hy", "*Armenian" },
- { "ia", "*Interlingua" },
- { "id", "*Indonesian" }, /* formerly in */
- { "ie", "*Interlingue" },
- { "ik", "*Inupiak" },
- { "in", "*Indonesian" }, /* replaced by id */
- { "is", "Islenska" },
- { "it", "Italiano" },
- { "iu", "*Inuktitut" },
- { "iw", "*Hebrew" }, /* replaced by he */
- { "ja", "*Japanese" },
- { "ji", "*Yiddish" }, /* replaced by yi */
- { "jw", "*Javanese" },
- { "ka", "*Georgian" },
- { "kk", "*Kazakh" },
- { "kl", "*Greenlandic" },
- { "km", "*Cambodian" },
- { "kn", "*Kannada" },
- { "ko", "*Korean" },
- { "ks", "*Kashmiri" },
- { "ku", "*Kurdish" },
- { "ky", "*Kirghiz" },
- { "la", "*Latin" },
- { "ln", "*Lingala" },
- { "lo", "*Laothian" },
- { "lt", "*Lithuanian" },
- { "lv", "*Latvian, Lettish" },
- { "mg", "*Malagasy" },
- { "mi", "*Maori" },
- { "mk", "*Macedonian" },
- { "ml", "*Malayalam" },
- { "mn", "*Mongolian" },
- { "mo", "*Moldavian" },
- { "mr", "*Marathi" },
- { "ms", "*Malay" },
- { "mt", "*Maltese" },
- { "my", "*Burmese" },
- { "na", "*Nauru" },
- { "ne", "*Nepali" },
- { "nl", "Nederlands" },
- { "no", "Norsk" },
- { "oc", "*Occitan" },
- { "om", "*(Afan) Oromo" },
- { "or", "*Oriya" },
- { "pa", "*Punjabi" },
- { "pl", "*Polish" },
- { "ps", "*Pashto, Pushto" },
- { "pt", "Portugues" },
- { "qu", "*Quechua" },
- { "rm", "*Rhaeto-Romance" },
- { "rn", "*Kirundi" },
- { "ro", "*Romanian" },
- { "ru", "*Russian" },
- { "rw", "*Kinyarwanda" },
- { "sa", "*Sanskrit" },
- { "sd", "*Sindhi" },
- { "sg", "*Sangho" },
- { "sh", "*Serbo-Croatian" },
- { "si", "*Sinhalese" },
- { "sk", "*Slovak" },
- { "sl", "*Slovenian" },
- { "sm", "*Samoan" },
- { "sn", "*Shona" },
- { "so", "*Somali" },
- { "sq", "*Albanian" },
- { "sr", "*Serbian" },
- { "ss", "*Siswati" },
- { "st", "*Sesotho" },
- { "su", "*Sundanese" },
- { "sv", "Svenska" },
- { "sw", "*Swahili" },
- { "ta", "*Tamil" },
- { "te", "*Telugu" },
- { "tg", "*Tajik" },
- { "th", "*Thai" },
- { "ti", "*Tigrinya" },
- { "tk", "*Turkmen" },
- { "tl", "*Tagalog" },
- { "tn", "*Setswana" },
- { "to", "*Tonga" },
- { "tr", "*Turkish" },
- { "ts", "*Tsonga" },
- { "tt", "*Tatar" },
- { "tw", "*Twi" },
- { "ug", "*Uighur" },
- { "uk", "*Ukrainian" },
- { "ur", "*Urdu" },
- { "uz", "*Uzbek" },
- { "vi", "*Vietnamese" },
- { "vo", "*Volapuk" },
- { "wo", "*Wolof" },
- { "xh", "*Xhosa" },
- { "yi", "*Yiddish" }, /* formerly ji */
- { "yo", "*Yoruba" },
- { "za", "*Zhuang" },
- { "zh", "*Chinese" },
- { "zu", "*Zulu" },
- { "\0", "" }
-};
+static const iso639_lang_t unknown_language =
+ { "Unknown", "Unknown", "??", "???", "???" };
/*****************************************************************************
- * DecodeLanguage: gives the long language name from the two-letters
+ * DecodeLanguage: gives the long language name from the two-letter
* ISO-639 code
*****************************************************************************/
-char * DecodeLanguage( u16 i_code )
+const char * DecodeLanguage( uint16_t i_code )
{
- int i = 0;
+ const iso639_lang_t * p_lang;
+ uint8_t psz_code[3];
- while( memcmp( lang_tbl[i].p_code, &i_code, 2 ) &&
- lang_tbl[i].p_lang_long[0] )
+ psz_code[0] = i_code >> 8;
+ psz_code[1] = i_code & 0xff;
+ psz_code[2] = '\0';
+
+ for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
{
- i++;
+ if( !memcmp( p_lang->psz_iso639_1, psz_code, 2 ) )
+ {
+# if 0
+ if( *p_lang->psz_native_name )
+ {
+ return p_lang->psz_native_name;
+ }
+#endif
+
+ return _( p_lang->psz_eng_name );
+ }
}
- return lang_tbl[i].p_lang_long;
+ return _( "Unknown" );
+}
+
+const iso639_lang_t * GetLang_1( const char * psz_code )
+{
+ const iso639_lang_t *p_lang;
+
+ for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
+ if( !strncmp( p_lang->psz_iso639_1, psz_code, 2 ) )
+ return p_lang;
+
+ return &unknown_language;
+}
+
+const iso639_lang_t * GetLang_2T( const char * psz_code )
+{
+ const iso639_lang_t *p_lang;
+
+ for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
+ if( !strncmp( p_lang->psz_iso639_2T, psz_code, 3 ) )
+ return p_lang;
+
+ return &unknown_language;
+}
+
+const iso639_lang_t * GetLang_2B( const char * psz_code )
+{
+ const iso639_lang_t *p_lang;
+
+ for( p_lang = p_languages; p_lang->psz_eng_name; p_lang++ )
+ if( !strncmp( p_lang->psz_iso639_2B, psz_code, 3 ) )
+ return p_lang;
+
+ return &unknown_language;
}