2 // Copyright (C) 2004 Tobas Glaesser <tobi.web@gmx.de>
3 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "supertux/language_menu.hpp"
20 #include "gui/menu_item.hpp"
21 #include "supertux/gameconfig.hpp"
23 LanguageMenu::LanguageMenu()
25 add_label(_("Language"));
27 add_entry(0, std::string("<")+_("auto-detect")+">");
28 add_entry(1, "English");
31 std::set<std::string> languages = dictionary_manager.get_languages();
32 for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
33 std::string locale_name = *i;
34 TinyGetText::LanguageDef ldef = TinyGetText::get_language_def(locale_name);
35 std::string locale_fullname = locale_name;
36 if (std::string(ldef.code) == locale_name) {
37 locale_fullname = ldef.name;
39 add_entry(mnid++, locale_fullname);
47 LanguageMenu::menu_action(MenuItem* item)
50 g_config->locale = "";
51 dictionary_manager.set_language(g_config->locale);
55 else if (item->id == 1) {
56 g_config->locale = "en";
57 dictionary_manager.set_language(g_config->locale);
62 std::set<std::string> languages = dictionary_manager.get_languages();
63 for (std::set<std::string>::iterator i = languages.begin(); i != languages.end(); i++) {
64 std::string locale_name = *i;
65 if (item->id == mnid++) {
66 g_config->locale = locale_name;
67 dictionary_manager.set_language(g_config->locale);