]> git.sesse.net Git - vlc/blobdiff - src/misc/darwin_specific.m
* initial Galician translation by Ivan. There are more translated strings to come...
[vlc] / src / misc / darwin_specific.m
index 63966e4d8cf1fee6287a10d2592c23d589e52821..0bff877ca156cd5b0d38dde9ed3343a75eaf4055 100644 (file)
@@ -1,17 +1,17 @@
 /*****************************************************************************
- * darwin_specific.m: Darwin specific features 
+ * 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 $
+ * Copyright (C) 2001-2004 the VideoLAN team
+ * $Id$
  *
- * Authors: Samuel Hocevar <sam@zoy.org>
+ * Authors: Sam Hocevar <sam@zoy.org>
  *          Christophe Massiot <massiot@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
 #include <vlc/vlc.h>
 
 #include <Cocoa/Cocoa.h>
+#include <CoreFoundation/CFString.h>
+
+#ifdef HAVE_LOCALE_H
+#   include <locale.h>
+#endif
 
 /*****************************************************************************
  * system_Init: fill in program path & retrieve language
  *****************************************************************************/
 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") )
+    const char ** ppsz_parser;
+    const char * ppsz_all[] =
     {
-        psz_short = "fr";
-    }
-    else if ( !strcmp(psz_lang, "Italian") )
+        "Catalan", "ca",
+        "Danish", "da",
+        "German", "de",
+        "British", "en_GB",
+        "English", "en",
+        "Spanish", "es",
+        "French", "fr",
+        "Galician", "gl",
+        "Italian", "it",
+        "Japanese", "ja",
+        "Korean", "ko",
+        "Dutch", "nl",
+        "Brazillian Portuguese", "pt_BR",
+        "Romanian", "ro",
+        "Russian", "ru",
+        "Turkish", "tr",
+        "Simplified Chinese", "zh_CN", 
+        "Chinese Traditional", "zh_TW",
+        NULL
+    };
+
+    for( ppsz_parser = ppsz_all ; ppsz_parser[0] ; ppsz_parser += 2 )
     {
-        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") )
-    {
-        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,36 +99,34 @@ 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. */
-        NSUserDefaults * o_defs = [NSUserDefaults standardUserDefaults]; 
-        NSArray * o_languages = [o_defs objectForKey:@"AppleLanguages"]; 
-        NSEnumerator * o_enumerator = [o_languages objectEnumerator]; 
+        NSUserDefaults * o_defs = [NSUserDefaults standardUserDefaults];
+        NSArray * o_languages = [o_defs objectForKey:@"AppleLanguages"];
+        NSEnumerator * o_enumerator = [o_languages objectEnumerator];
         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];
     }
+
+    vlc_mutex_init( p_this, &p_this->p_libvlc->iconv_lock );
+    p_this->p_libvlc->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
 }
 
 /*****************************************************************************
  * system_Configure: check for system specific configuration options.
  *****************************************************************************/
-void system_Configure( vlc_t *p_this )
+void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
 {
 
 }
@@ -153,5 +137,9 @@ void system_Configure( vlc_t *p_this )
 void system_End( vlc_t *p_this )
 {
     free( p_this->p_libvlc->psz_vlcpath );
+
+    if ( p_this->p_libvlc->iconv_macosx != (vlc_iconv_t)-1 )
+        vlc_iconv_close( p_this->p_libvlc->iconv_macosx );
+    vlc_mutex_destroy( &p_this->p_libvlc->iconv_lock );
 }