From c8c05a3451c74c20a77b2518aab265ab1a8f4465 Mon Sep 17 00:00:00 2001 From: wolfgangb Date: Fri, 6 May 2011 22:31:44 +0000 Subject: [PATCH] Determine language on start-up if language is set to auto detect. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6687 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- src/supertux/main.cpp | 9 +++++++++ src/supertux/menu/language_menu.cpp | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 41dc6227d..3dccd6e38 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -23,6 +23,9 @@ #include #include #include +extern "C" { +#include +} #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); } } diff --git a/src/supertux/menu/language_menu.cpp b/src/supertux/menu/language_menu.cpp index 136a28468..fab8544d1 100644 --- a/src/supertux/menu/language_menu.cpp +++ b/src/supertux/menu/language_menu.cpp @@ -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(); } -- 2.11.0