00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <string.h>
00025 #include <stdlib.h>
00026
00027 #include <vlc/vlc.h>
00028
00029 #include <Cocoa/Cocoa.h>
00030 #include <CoreFoundation/CFString.h>
00031
00032 #ifdef HAVE_LOCALE_H
00033 # include <locale.h>
00034 #endif
00035
00036
00037
00038
00039 static int FindLanguage( const char * psz_lang )
00040 {
00041 const char ** ppsz_parser;
00042 const char * ppsz_all[] =
00043 {
00044 "Catalan", "ca",
00045 "Danish", "da",
00046 "German", "de",
00047 "British", "en_GB",
00048 "English", "en",
00049 "Spanish", "es",
00050 "French", "fr",
00051 "Galician", "gl",
00052 "Italian", "it",
00053 "Japanese", "ja",
00054 "Korean", "ko",
00055 "Dutch", "nl",
00056 "Brazillian Portuguese", "pt_BR",
00057 "Romanian", "ro",
00058 "Russian", "ru",
00059 "Turkish", "tr",
00060 "Simplified Chinese", "zh_CN",
00061 "Chinese Traditional", "zh_TW",
00062 NULL
00063 };
00064
00065 for( ppsz_parser = ppsz_all ; ppsz_parser[0] ; ppsz_parser += 2 )
00066 {
00067 if( !strcmp( psz_lang, ppsz_parser[0] )
00068 || !strcmp( psz_lang, ppsz_parser[1] ) )
00069 {
00070 setenv( "LANG", ppsz_parser[1], 1 );
00071 return 1;
00072 }
00073 }
00074
00075 return 0;
00076 }
00077
00078 void system_Init( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
00079 {
00080 char i_dummy;
00081 char *p_char, *p_oldchar = &i_dummy;
00082
00083
00084 p_char = p_this->p_libvlc->psz_vlcpath = strdup( ppsz_argv[ 0 ] );
00085
00086
00087 for( ; *p_char ; )
00088 {
00089 if( *p_char == '/' )
00090 {
00091 *p_oldchar = '/';
00092 *p_char = '\0';
00093 p_oldchar = p_char;
00094 }
00095
00096 p_char++;
00097 }
00098
00099
00100 if ( (p_char = getenv("LANG")) == NULL )
00101 {
00102 NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
00103
00104
00105 NSUserDefaults * o_defs = [NSUserDefaults standardUserDefaults];
00106 NSArray * o_languages = [o_defs objectForKey:@"AppleLanguages"];
00107 NSEnumerator * o_enumerator = [o_languages objectEnumerator];
00108 NSString * o_lang;
00109
00110 while ( (o_lang = [o_enumerator nextObject]) )
00111 {
00112 const char * psz_string = [o_lang lossyCString];
00113 if ( FindLanguage( psz_string ) )
00114 {
00115 break;
00116 }
00117 }
00118
00119 [o_pool release];
00120 }
00121
00122 vlc_mutex_init( p_this, &p_this->p_libvlc->iconv_lock );
00123 p_this->p_libvlc->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
00124 }
00125
00126
00127
00128
00129 void system_Configure( vlc_t *p_this, int *pi_argc, char *ppsz_argv[] )
00130 {
00131
00132 }
00133
00134
00135
00136
00137 void system_End( vlc_t *p_this )
00138 {
00139 free( p_this->p_libvlc->psz_vlcpath );
00140
00141 if ( p_this->p_libvlc->iconv_macosx != (vlc_iconv_t)-1 )
00142 vlc_iconv_close( p_this->p_libvlc->iconv_macosx );
00143 vlc_mutex_destroy( &p_this->p_libvlc->iconv_lock );
00144 }
00145