[vlc-commits] bin: re-implement --language for OS X
Felix Paul Kühne
git at videolan.org
Sun Nov 10 11:09:55 CET 2013
vlc/vlc-2.1 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sat Nov 9 18:03:46 2013 +0100| [ecb2727972d445f1ebe49063efacec17e1c0c66c] | committer: Felix Paul Kühne
bin: re-implement --language for OS X
(cherry picked from commit bd184a14413e098e273734bf8bc1f615e967fea5)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=ecb2727972d445f1ebe49063efacec17e1c0c66c
---
bin/Makefile.am | 3 +++
bin/darwinvlc.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+)
diff --git a/bin/Makefile.am b/bin/Makefile.am
index d4b3f01..ad3967e 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -33,6 +33,9 @@ vlc_wrapper_SOURCES = rootwrap.c
vlc_wrapper_LDADD = $(SOCKET_LIBS)
vlc_LDFLAGS = $(LDFLAGS_vlc)
+if HAVE_DARWIN
+vlc_LDFLAGS += -Wl,-framework,CoreFoundation
+endif
vlc_LDADD = ../lib/libvlc.la $(LIBPTHREAD)
vlc_static_SOURCES = $(vlc_SOURCES)
diff --git a/bin/darwinvlc.c b/bin/darwinvlc.c
index 8c016ef..4b6847a 100644
--- a/bin/darwinvlc.c
+++ b/bin/darwinvlc.c
@@ -40,6 +40,8 @@
# include <pthread.h>
#endif
#include <unistd.h>
+#include <TargetConditionals.h>
+#import <CoreFoundation/CoreFoundation.h>
extern void vlc_enable_override (void);
@@ -154,6 +156,37 @@ int main( int i_argc, const char *ppsz_argv[] )
argv[argc++] = "--no-ignore-config";
argv[argc++] = "--media-library";
+
+ /* overwrite system language on Mac */
+#if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR // TARGET_OS_MAC is unspecific
+ char *lang = NULL;
+
+ for (int i = 0; i < i_argc; i++) {
+ if (!strncmp(ppsz_argv[i], "--language", 10)) {
+ lang = strstr(ppsz_argv[i], "=");
+ ppsz_argv++, i_argc--;
+ continue;
+ }
+ }
+
+ if (!lang) {
+ CFStringRef language;
+ language = (CFStringRef)CFPreferencesCopyAppValue(CFSTR("language"),
+ kCFPreferencesCurrentApplication);
+ if (language) {
+ if (CFStringGetLength(language) > 0)
+ lang = (char *)CFStringGetCStringPtr(language, kCFStringEncodingUTF8);
+ CFRelease(language);
+ }
+ }
+
+ if (lang && strncmp( lang, "auto", 4 )) {
+ char tmp[11];
+ snprintf(tmp, 11, "LANG%s", lang);
+ putenv(tmp);
+ }
+#endif
+
ppsz_argv++; i_argc--; /* skip executable path */
/* When VLC.app is run by double clicking in Mac OS X, the 2nd arg
More information about the vlc-commits
mailing list