[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/qt main.cpp
From: |
Olivier Teulière |
Subject: |
[Eliot-dev] eliot/qt main.cpp |
Date: |
Sun, 07 Feb 2010 17:34:59 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Changes by: Olivier Teulière <ipkiss> 10/02/07 17:34:59
Modified files:
qt : main.cpp
Log message:
Workaround encoding issues on Mac OS X: when Eliot is started from the
dock, the LANG variable is not set. So retrieve the language from the
preferences, and force encoding to UTF-8.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/main.cpp?cvsroot=eliot&r1=1.5&r2=1.6
Patches:
Index: main.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/main.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- main.cpp 29 Jan 2010 21:11:44 -0000 1.5
+++ main.cpp 7 Feb 2010 17:34:59 -0000 1.6
@@ -29,8 +29,7 @@
# include <windows.h>
#endif
#ifdef __APPLE__
-# include <CoreFoundation/CFURL.h>
-# include <CoreFoundation/CFBundle.h>
+# include <CoreFoundation/CoreFoundation.h>
#endif
using std::string;
@@ -38,9 +37,44 @@
int main(int argc, char **argv)
{
+ // On Mac, running Eliot from the dock does not automatically set the LANG
+ // variable, so we do it ourselves.
+ // Note: The following block of code is copied from VLC, and slightly
+ // modified by me (original author: Pierre d'Herbemont)
+#if defined(ENABLE_NLS) && defined(__APPLE__)
+ /* Check if $LANG is set. */
+ if (NULL == getenv("LANG"))
+ {
+ // Retrieve the preferred language as chosen in System Preferences.app
+ // (note that CFLocaleCopyCurrent() is not used because it returns the
+ // preferred locale not language)
+ CFArrayRef all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
+ CFArrayRef preferred_locales =
CFBundleCopyLocalizationsForPreferences(all_locales, NULL);
+
+ if (preferred_locales)
+ {
+ if (CFArrayGetCount(preferred_locales))
+ {
+ char psz_locale[50];
+ CFStringRef user_language_string_ref = (CFStringRef)
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);
+ }
+#endif
+
+
#ifdef HAVE_SETLOCALE
// Set locale via LC_ALL
setlocale(LC_ALL, "");
+#ifdef __APPLE__
+ // FIXME: Ugly hack: we hardcode the encoding to UTF-8, because I don't
+ // know how to retrieve it properly
+ setlocale(LC_CTYPE, "UTF-8");
+#endif
#endif
QApplication app(argc, argv);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/qt main.cpp,
Olivier Teulière <=