+
+ /* Check if $LANG is set. */
+ if ( (p_char = getenv("LANG")) == NULL )
+ {
+ /*
+ Retrieve the preferred language as chosen in System Preferences.app
+ (note that CFLocaleCopyCurrent() is not used because it returns the
+ prefered locale not language)
+ */
+ CFArrayRef all_locales, preferred_locales;
+ char psz_locale[50];
+
+ if( CFLocaleCopyAvailableLocaleIdentifiers )
+ all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
+ else
+ all_locales = copy_all_locale_indentifiers();
+
+ preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
+
+ if ( preferred_locales )
+ {
+ if ( CFArrayGetCount( preferred_locales ) )
+ {
+ CFStringRef user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
+ CFStringGetCString( user_language_string_ref, psz_locale, sizeof(psz_locale), kCFStringEncodingUTF8 );
+ setenv( "LANG", psz_locale, 1 );
+ }
+ CFRelease( preferred_locales );
+ }
+ CFRelease( all_locales );
+ }
+
+ vlc_mutex_init( p_this, &vlc_global( p_this )->iconv_lock );
+ vlc_global( p_this )->iconv_macosx = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );