]> git.sesse.net Git - vlc/blob - src/darwin/specific.c
configure: simplify header tests
[vlc] / src / darwin / specific.c
1
2 /*****************************************************************************
3  * darwin_specific.m: Darwin specific features
4  *****************************************************************************
5  * Copyright (C) 2001-2009 VLC authors and VideoLAN
6  * $Id$
7  *
8  * Authors: Sam Hocevar <sam@zoy.org>
9  *          Christophe Massiot <massiot@via.ecp.fr>
10  *          Pierre d'Herbemont <pdherbemont@free.fr>
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU Lesser General Public License as published by
14  * the Free Software Foundation; either version 2.1 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <vlc_common.h>
32 #include "../libvlc.h"
33 #include <dirent.h>                                                /* *dir() */
34 #include <CoreFoundation/CoreFoundation.h>
35
36 #include <locale.h>
37
38 /*****************************************************************************
39  * system_Init: fill in program path & retrieve language
40  *****************************************************************************/
41 void system_Init(void)
42 {
43 #ifdef ENABLE_NLS
44     /* Check if $LANG is set. */
45     if( NULL == getenv("LANG") )
46     {
47         /*
48            Retrieve the preferred language as chosen in  System Preferences.app
49            (note that CFLocaleCopyCurrent() is not used because it returns the
50             preferred locale not language)
51         */
52         CFArrayRef all_locales, preferred_locales;
53         char psz_locale[50];
54
55         all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
56
57         preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
58
59         if ( preferred_locales )
60         {
61             if ( CFArrayGetCount( preferred_locales ) )
62             {
63                 CFStringRef user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
64                 CFStringGetCString( user_language_string_ref, psz_locale, sizeof(psz_locale), kCFStringEncodingUTF8 );
65                 setenv( "LANG", psz_locale, 1 );
66             }
67             CFRelease( preferred_locales );
68         }
69         CFRelease( all_locales );
70     }
71 #endif
72 }
73
74 /*****************************************************************************
75  * system_Configure: check for system specific configuration options.
76  *****************************************************************************/
77 void system_Configure( libvlc_int_t *p_this,
78                        int i_argc, const char *const ppsz_argv[] )
79 {
80     (void)p_this;
81     (void)i_argc;
82     (void)ppsz_argv;
83 }