From: Wolfgang Becker Date: Fri, 6 May 2011 22:31:44 +0000 (+0000) Subject: Determine language on start-up if language is set to auto detect. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=4c8cad0bc3655019b31821279cc48d4959ce2f81;p=supertux.git Determine language on start-up if language is set to auto detect. SVN-Revision: 6687 --- 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(); }