LanguageMenu Class Reference

#include <language_menu.hpp>

Inherits Menu.

List of all members.

Public Member Functions

 LanguageMenu ()
void menu_action (MenuItem *item)
void check_menu ()


Detailed Description

Definition at line 24 of file language_menu.hpp.


Constructor & Destructor Documentation

LanguageMenu::LanguageMenu (  ) 

Definition at line 34 of file language_menu.cpp.

References _(), Menu::add_back(), Menu::add_entry(), Menu::add_hl(), Menu::add_label(), dictionary_manager, MNID_LANGUAGE_AUTO_DETECT, MNID_LANGUAGE_ENGLISH, and MNID_LANGUAGE_NEXT.

00035 {
00036   add_label(_("Language"));
00037   add_hl();
00038   add_entry(MNID_LANGUAGE_AUTO_DETECT, _("<auto-detect>"));
00039   add_entry(MNID_LANGUAGE_ENGLISH, "English");
00040 
00041   int mnid = MNID_LANGUAGE_NEXT;
00042   std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
00043   for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++) 
00044   {
00045     add_entry(mnid++, i->get_name());
00046   }
00047 
00048   add_hl();
00049   add_back(_("Back"));
00050 }


Member Function Documentation

void LanguageMenu::menu_action ( MenuItem item  )  [virtual]

Reimplemented from Menu.

Definition at line 53 of file language_menu.cpp.

References FL_Locale::country, dictionary_manager, FL_FindLocale(), FL_FreeLocale(), FL_MESSAGES, g_config, MenuItem::id, FL_Locale::lang, Config::locale, MNID_LANGUAGE_AUTO_DETECT, MNID_LANGUAGE_ENGLISH, MNID_LANGUAGE_NEXT, MenuManager::pop_current(), Config::save(), and FL_Locale::variant.

00054 {
00055   if (item->id == MNID_LANGUAGE_AUTO_DETECT) // auto detect
00056   {
00057     FL_Locale *locale;
00058     FL_FindLocale(&locale, FL_MESSAGES);
00059     tinygettext::Language language = tinygettext::Language::from_spec( locale->lang?locale->lang:"", locale->country?locale->country:"", locale->variant?locale->variant:"");
00060     FL_FreeLocale(&locale);
00061 
00062     dictionary_manager->set_language(language); // set currently detected language
00063     g_config->locale = ""; // do auto detect every time on startup
00064     g_config->save();
00065     MenuManager::pop_current();
00066   }
00067   else if (item->id == MNID_LANGUAGE_ENGLISH) // english
00068   {
00069     g_config->locale = "en";
00070     dictionary_manager->set_language(tinygettext::Language::from_name(g_config->locale));
00071     g_config->save();
00072     MenuManager::pop_current();
00073   }
00074   else
00075   {
00076     int mnid = MNID_LANGUAGE_NEXT;
00077     std::set<tinygettext::Language> languages = dictionary_manager->get_languages();
00078 
00079     for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); i++) 
00080     {
00081       if (item->id == mnid++) 
00082       {
00083         g_config->locale = i->str();
00084         dictionary_manager->set_language(*i);
00085         g_config->save();
00086         MenuManager::pop_current();
00087         break;
00088       }
00089     }
00090   }
00091 }

void LanguageMenu::check_menu (  )  [inline, virtual]

Implements Menu.

Definition at line 30 of file language_menu.hpp.

00030 {}


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:31 2014 for SuperTux by  doxygen 1.5.1