OSX/locale: moved command up, so errorchecking also happens
authorJens Verwiebe <info@jensverwiebe.de>
Wed, 21 Nov 2012 14:29:34 +0000 (14:29 +0000)
committerJens Verwiebe <info@jensverwiebe.de>
Wed, 21 Nov 2012 14:29:34 +0000 (14:29 +0000)
intern/locale/boost_locale_wrapper.cpp

index 7b317da1edf2edeaa0fbad768052c44f078b94c1..657f680d5131e20ec88b0546706510eaf2e1e343 100644 (file)
@@ -58,25 +58,25 @@ void bl_locale_set(const char *locale)
        // Specify location of dictionaries.
        gen.add_messages_path(messages_path);
        gen.add_messages_domain(default_domain);
-       //gen.set_default_messages_domain(default_domain);
-
+       //gen.set_default_messages_domain(default_domain);      
+#if defined (__APPLE__)
+       // workaround to get osx system locale from user defaults
+       FILE* fp;
+       char result [10];
+       char osx_locale [10];
+       fp = popen("defaults read .GlobalPreferences AppleLocale","r");
+       fread(result,1,sizeof(result),fp);
+       fclose (fp);
+       sprintf(osx_locale, """%s.UTF-8""", result);
+       locale = osx_locale;
+#endif
        if (locale && locale[0]) {
                std::locale::global(gen(locale));
        }
+
        else {
-#if defined (__APPLE__)
-               // workaround to get osx system locale from user defaults
-               FILE* fp;
-               char result [10];
-               char osx_locale [10];
-               fp = popen("defaults read .GlobalPreferences AppleLocale","r");
-               fread(result,1,sizeof(result),fp);
-               fclose (fp);
-               sprintf(osx_locale, """%s.UTF-8""", result);
-               std::locale::global(gen(osx_locale));
-#else
+
                std::locale::global(gen(""));
-#endif
        }
        // Note: boost always uses "C" LC_NUMERIC by default!
 }