]> git.sesse.net Git - vlc/blobdiff - src/misc/darwin_specific.m
* Fixed the localization issue on MacOSX.
[vlc] / src / misc / darwin_specific.m
index 63966e4d8cf1fee6287a10d2592c23d589e52821..00fd0b71bf70dc33cd0146632511261d2132442a 100644 (file)
@@ -2,7 +2,7 @@
  * darwin_specific.m: Darwin specific features 
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: darwin_specific.m,v 1.7 2003/01/19 03:16:24 sam Exp $
+ * $Id: darwin_specific.m,v 1.12 2003/02/17 23:47:29 hartman Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Christophe Massiot <massiot@via.ecp.fr>
  *****************************************************************************/
 static int FindLanguage( const char * psz_lang )
 {
-    const char * psz_short = NULL;
-
-    if ( !strcmp(psz_lang, "German") )
-    {
-        psz_short = "de";
-    }
-    else if ( !strcmp(psz_lang, "British") )
-    {
-        psz_short = "en_GB";
-    }
-    else if ( !strcmp(psz_lang, "French") )
-    {
-        psz_short = "fr";
-    }
-    else if ( !strcmp(psz_lang, "Italian") )
+    const char ** ppsz_parser;
+    const char * ppsz_all[] =
     {
-        psz_short = "it";
-    }
-    else if ( !strcmp(psz_lang, "Japanese") )
-    {
-        psz_short = "ja";
-    }
-    else if ( !strcmp(psz_lang, "Dutch") )
-    {
-        psz_short = "nl";
-    }
-    else if ( !strcmp(psz_lang, "no") )
-    {
-        psz_short = "no";
-    }
-    else if ( !strcmp(psz_lang, "pl") )
+        "German", "de",
+        "British", "en_GB",
+        "English", "en",
+        "French", "fr",
+        "Italian", "it",
+        "Japanese", "ja",
+        "Dutch", "nl",
+        "Norwegian", "no",
+        "Polish", "pl",
+        "Russian", "ru",
+        "Swedish", "sv",
+       NULL
+    };
+
+    for( ppsz_parser = ppsz_all ; ppsz_parser[0] ; ppsz_parser += 2 )
     {
-        psz_short = "pl";
-    }
-    else if ( !strcmp(psz_lang, "ru") )
-    {
-        psz_short = "ru";
-    }
-    else if ( !strcmp(psz_lang, "sv") )
-    {
-        psz_short = "sv";
-    }
-    else if ( !strcmp(psz_lang, "English") )
-    {
-        psz_short = "C";
-    }
-
-    if ( psz_short != NULL )
-    {
-        setenv("LANG", psz_short, 1);
-        return 1;
+        if( !strcmp( psz_lang, ppsz_parser[0] )
+             || !strcmp( psz_lang, ppsz_parser[1] ) )
+        {
+            setenv( "LANG", ppsz_parser[1], 1 );
+            return 1;
+        }
     }
 
     return 0;
@@ -113,7 +87,6 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
     /* Check if $LANG is set. */
     if ( (p_char = getenv("LANG")) == NULL )
     {
-        vlc_bool_t b_found = 0;
         NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
 
         /* Retrieve user's preferences. */
@@ -123,18 +96,14 @@ void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
         NSString * o_lang;
 
         while ( (o_lang = [o_enumerator nextObject]) )
-        {
-            if( !b_found )
-            { 
-                const char * psz_string = [o_lang lossyCString];
-                if ( FindLanguage( psz_string ) )
-                {
-                    b_found = 1;
-                }
+        { 
+            const char * psz_string = [o_lang lossyCString];
+            if ( FindLanguage( psz_string ) )
+            {
+                break;
             }
         }
-
-        [o_languages release];
+        
         [o_pool release];
     }
 }