Determine language on start-up if language is set to auto detect.
authorwolfgangb <wolfgangb@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Fri, 6 May 2011 22:31:44 +0000 (22:31 +0000)
committerwolfgangb <wolfgangb@837edb03-e0f3-0310-88ca-d4d4e8b29345>
Fri, 6 May 2011 22:31:44 +0000 (22:31 +0000)
git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6687 837edb03-e0f3-0310-88ca-d4d4e8b29345

src/supertux/main.cpp
src/supertux/menu/language_menu.cpp

index 41dc622..3dccd6e 100644 (file)
@@ -23,6 +23,9 @@
 #include <binreloc.h>
 #include <tinygettext/log.hpp>
 #include <boost/format.hpp>
+extern "C" {
+#include <findlocale.h>
+}
 
 #include "supertux/main.hpp"
 
@@ -84,6 +87,12 @@ Main::init_tinygettext()
   if (g_config->locale != "") 
   {
     dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
+  } else {
+    FL_Locale *locale;
+    FL_FindLocale(&locale, FL_MESSAGES);
+    tinygettext::Language language = tinygettext::Language::from_spec( locale->lang?locale->lang:"", locale->country?locale->country:"", locale->variant?locale->variant:"");
+    FL_FreeLocale(&locale);
+    dictionary_manager->set_language(language);
   }
 }
 
index 136a284..fab8544 100644 (file)
@@ -56,11 +56,11 @@ LanguageMenu::menu_action(MenuItem* item)
   {
     FL_Locale *locale;
     FL_FindLocale(&locale, FL_MESSAGES);
-    tinygettext::Language language = tinygettext::Language::from_spec(locale->lang, locale->country, locale->variant);
+    tinygettext::Language language = tinygettext::Language::from_spec( locale->lang?locale->lang:"", locale->country?locale->country:"", locale->variant?locale->variant:"");
     FL_FreeLocale(&locale);
 
-    dictionary_manager->set_language(language);
-    g_config->locale = language.str();
+    dictionary_manager->set_language(language); // set currently detected language
+    g_config->locale = ""; // do auto detect every time on startup
     g_config->save();
     MenuManager::pop_current();
   }