本文整理汇总了C++中tinygettext::DictionaryManager::get_languages方法的典型用法代码示例。如果您正苦于以下问题:C++ DictionaryManager::get_languages方法的具体用法?C++ DictionaryManager::get_languages怎么用?C++ DictionaryManager::get_languages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinygettext::DictionaryManager
的用法示例。
在下文中一共展示了DictionaryManager::get_languages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: I18N_Init
/**
* @brief Attempts to detect the system language unless cl_lang was already set.
* Then loads the PO file containing translated strings.
*/
void I18N_Init(void)
{
FL_Locale *locale;
std::set<tinygettext::Language> languages;
std::set<tinygettext::Language> languages_mod;
cl_lang = Cvar_Get("cl_lang", "en", CVAR_ARCHIVE | CVAR_LATCH);
cl_langDebug = Cvar_Get("cl_langDebug", "0", CVAR_ARCHIVE);
tinygettext::Log::set_log_error_callback(&Tinygettext_Error);
tinygettext::Log::set_log_info_callback(&Tinygettext_Info);
tinygettext::Log::set_log_warning_callback(&Tinygettext_Warning);
FL_FindLocale(&locale);
// Do not change the language if it is already set
if (!cl_lang->string[0])
{
// locale->country is also supported for 'en_US' format
if (locale->lang && locale->lang[0])
{
Cvar_Set("cl_lang", va("%s", locale->lang));
}
else
{
// Language detection failed. Fallback to English
Cvar_Set("cl_lang", "en");
}
}
dictionary.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new QFileSystem));
dictionary_mod.set_filesystem(std::auto_ptr<tinygettext::FileSystem>(new QFileSystem));
dictionary.add_directory("locale/client");
dictionary_mod.add_directory("locale/mod");
languages = dictionary.get_languages();
Com_Printf("Available client translations:");
for (std::set<tinygettext::Language>::iterator p = languages.begin(); p != languages.end(); p++)
{
Com_Printf(" %s", p->get_name().c_str());
}
Com_Printf("\n");
languages_mod = dictionary_mod.get_languages();
Com_Printf("Available mod translations:");
for (std::set<tinygettext::Language>::iterator p = languages_mod.begin(); p != languages_mod.end(); p++)
{
Com_Printf(" %s", p->get_name().c_str());
}
Com_Printf("\n");
I18N_SetLanguage(cl_lang->string);
FL_FreeLocale(&locale);
}
示例2: exit
void
PingusMain::apply_args()
{
// FIXME: merge cmd_options with stuff read from config file here
auto& options = cmd_options;
// Mode toggles
if (options.list_languages.is_set() &&
options.list_languages.get())
{ // language listing only works after the data path has been set
std::cout << "Available languages are:" << std::endl;
std::cout << "========================" << std::endl;
std::set<tinygettext::Language> lst = dictionary_manager.get_languages();
for (std::set<tinygettext::Language>::iterator i = lst.begin(); i != lst.end(); ++i)
std::cout << i->get_name() << " (" << i->str() << ")" << std::endl;
std::cout << "\nLanguages can be used via:\n\n pingus --language de\n" << std::endl;
exit(EXIT_SUCCESS);
}
if (options.software_cursor.is_set())
globals::software_cursor = options.software_cursor.get();
// Sound
if (options.disable_music.is_set())
globals::music_enabled = !options.disable_music.get();
if (options.disable_sound.is_set())
globals::sound_enabled = !options.disable_sound.get();
// Misc
if (options.language.is_set())
dictionary_manager.set_language(tinygettext::Language::from_name(options.language.get()));
if (options.auto_scrolling.is_set())
globals::auto_scrolling = options.auto_scrolling.get();
if (options.drag_drop_scrolling.is_set())
globals::drag_drop_scrolling = options.drag_drop_scrolling.get();
if (options.developer_mode.is_set())
globals::developer_mode = options.developer_mode.get();
if (options.speed.is_set())
globals::game_speed = options.speed.get();
if (options.desiredfps.is_set())
globals::desired_fps = options.desiredfps.get();
if (options.tile_size.is_set())
globals::tile_size = options.tile_size.get();
}
示例3: background
OptionMenu::OptionMenu() :
background(),
ok_button(),
x_pos(),
y_pos(),
options(),
fullscreen_box(),
swcursor_box(),
autoscroll_box(),
mousegrab_box(),
printfps_box(),
master_volume_box(),
sound_volume_box(),
music_volume_box(),
defaults_label(),
defaults_box(),
connections(),
language(),
language_map()
{
background = Sprite("core/menu/optionmenu");
gui_manager->add(ok_button = new OptionMenuCloseButton(this,
Display::get_width()/2 + 225,
Display::get_height()/2 + 125));
x_pos = 0;
y_pos = 0;
int resolutions[][2] = {
{ 640, 480 }, // 4:3, VGA
{ 768, 576 }, // 4:3, PAL
{ 800, 480 }, // Nokia N770, N800
{ 800, 600 }, // 4:3, SVGA
{ 1024, 768 }, // 4:3, XGA
{ 1152, 864 }, // 4:3
{ 1280, 720 }, // 16:9, HD-TV, 720p
{ 1280, 960 }, // 4:3
{ 1280, 1024 }, // 5:4
{ 1366, 768 }, // ~16:9, Wide XGA
{ 1440, 900, }, // 16:10
{ 1600, 1200 }, // 4:3, UXGA
{ 1680, 1050 }, // 16:10, WSXGA
{ 1920, 1080 }, // 16:9, HD-TV, 1080p
{ 1920, 1200 }, // 16:10
{ -1, -1 }
};
int current_choice = -1;
int n;
ChoiceBox* resolution_box = new ChoiceBox(Rect());
for (n = 0; resolutions[n][0] != -1; ++n)
{
std::ostringstream ostr;
ostr << resolutions[n][0] << "x" << resolutions[n][1];
resolution_box->add_choice(ostr.str());
if (Display::get_width() == resolutions[n][0] &&
Display::get_height() == resolutions[n][1])
{
current_choice = n;
}
}
resolution_box->add_choice("Custom");
if (current_choice == -1)
current_choice = n;
resolution_box->set_current_choice(current_choice);
tinygettext::Language current_language = dictionary_manager.get_language();
language = current_language;
n = 0;
ChoiceBox* language_box = new ChoiceBox(Rect());
std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
for (std::set<tinygettext::Language>::iterator i = languages.begin(); i != languages.end(); ++i)
{
language_box->add_choice(i->str());
if (current_language == *i)
language_box->set_current_choice(current_choice);
}
ChoiceBox* scroll_box = new ChoiceBox(Rect());
scroll_box->add_choice("Drag&Drop");
scroll_box->add_choice("Rubberband");
swcursor_box = new CheckBox(Rect());
fullscreen_box = new CheckBox(Rect());
autoscroll_box = new CheckBox(Rect());
mousegrab_box = new CheckBox(Rect());
printfps_box = new CheckBox(Rect());
master_volume_box = new SliderBox(Rect());
sound_volume_box = new SliderBox(Rect());
music_volume_box = new SliderBox(Rect());
C(swcursor_box->on_change.connect(std::bind(&OptionMenu::on_swcursor_change, this, std::placeholders::_1)));
C(fullscreen_box->on_change.connect(std::bind(&OptionMenu::on_fullscreen_change, this, std::placeholders::_1)));
C(autoscroll_box->on_change.connect(std::bind(&OptionMenu::on_autoscroll_change, this, std::placeholders::_1)));
C(mousegrab_box->on_change.connect(std::bind(&OptionMenu::on_mousegrab_change, this, std::placeholders::_1)));
C(printfps_box->on_change.connect(std::bind(&OptionMenu::on_printfps_change, this, std::placeholders::_1)));
//.........这里部分代码省略.........
示例4: options
OptionMenu::OptionMenu() :
m_background("core/menu/wood"),
m_blackboard("core/menu/blackboard"),
ok_button(),
x_pos(),
y_pos(),
options(),
fullscreen_box(),
software_cursor_box(),
autoscroll_box(),
dragdrop_scroll_box(),
mousegrab_box(),
printfps_box(),
master_volume_box(),
sound_volume_box(),
music_volume_box(),
//defaults_label(),
//defaults_box(),
connections(),
m_language(),
m_language_map()
{
gui_manager->add(ok_button = new OptionMenuCloseButton(this,
Display::get_width()/2 + 245,
Display::get_height()/2 + 150));
x_pos = 0;
y_pos = 0;
ChoiceBox* resolution_box = new ChoiceBox(Rect());
{
std::vector<SDL_DisplayMode> resolutions = Display::get_fullscreen_video_modes();
Size fullscreen = config_manager.get_fullscreen_resolution();
int choice = static_cast<int>(resolutions.size()) - 1;
for (auto it = resolutions.begin(); it != resolutions.end(); ++it)
{
// add resolution to the box
std::ostringstream ostr;
ostr << it->w << "x" << it->h << "@" << it->refresh_rate;
resolution_box->add_choice(ostr.str());
// FIXME: ignoring refresh_rate
if (fullscreen.width == it->w &&
fullscreen.height == it->h)
{
choice = static_cast<int>(it - resolutions.begin());
}
}
resolution_box->set_current_choice(choice);
}
ChoiceBox* renderer_box = new ChoiceBox(Rect());
renderer_box->add_choice("sdl");
renderer_box->add_choice("delta");
renderer_box->add_choice("opengl");
switch(config_manager.get_renderer())
{
case SDL_FRAMEBUFFER: renderer_box->set_current_choice(0); break;
case DELTA_FRAMEBUFFER: renderer_box->set_current_choice(1); break;
case OPENGL_FRAMEBUFFER: renderer_box->set_current_choice(2); break;
default: assert(!"unknown renderer type");
}
m_language = dictionary_manager.get_language();
ChoiceBox* language_box = new ChoiceBox(Rect());
{
std::set<tinygettext::Language> languages = dictionary_manager.get_languages();
// English is the default language, thus it's not in the list of
// languages returned by tinygettext and we have to add it manually
languages.insert(tinygettext::Language::from_name("en"));
std::vector<tinygettext::Language> langs(languages.begin(), languages.end());
std::sort(langs.begin(), langs.end(), LanguageSorter());
for (auto i = langs.begin(); i != langs.end(); ++i)
{
m_language_map[i->get_name()] = *i;
language_box->add_choice(i->get_name());
if (m_language == *i)
{
language_box->set_current_choice(static_cast<int>(i - langs.begin()));
}
}
}
ChoiceBox* scroll_box = new ChoiceBox(Rect());
scroll_box->add_choice("Drag&Drop");
scroll_box->add_choice("Rubberband");
software_cursor_box = new CheckBox(Rect());
fullscreen_box = new CheckBox(Rect());
autoscroll_box = new CheckBox(Rect());
dragdrop_scroll_box = new CheckBox(Rect());
mousegrab_box = new CheckBox(Rect());
//.........这里部分代码省略.........