Skip to content

Commit

Permalink
Determine language on start-up if language is set to auto detect.
Browse files Browse the repository at this point in the history
SVN-Revision: 6687
  • Loading branch information
uafr committed May 6, 2011
1 parent c3c06d2 commit 4c8cad0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/supertux/main.cpp
Expand Up @@ -23,6 +23,9 @@
#include <binreloc.h>
#include <tinygettext/log.hpp>
#include <boost/format.hpp>
extern "C" {
#include <findlocale.h>
}

#include "supertux/main.hpp"

Expand Down Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/supertux/menu/language_menu.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit 4c8cad0

Please sign in to comment.