The Battle for Wesnoth  1.15.2+dev
Namespaces | Macros | Functions
gettext.hpp File Reference
#include "wesconfig.h"
#include <string>
#include <vector>
#include <ctime>
Include dependency graph for gettext.hpp:

Go to the source code of this file.

Namespaces

 translation
 

Macros

#define GETTEXT_DOMAIN   PACKAGE
 How to use gettext for wesnoth source files:

  1. include this header file in the .cpp file
  2. make sure, that the source file is listed in the respective POTFILES.in for the textdomain, in the case of wesnoth-lib it is this file: po/wesnoth-lib/POTFILES.in
  3. add the following include to set the correct textdomain, in this example wesnoth-lib (not required for the domain 'wesnoth', required for all other textdomains).
More...
 
#define UNUSEDNOWARN
 
#define gettext_noop(String)   String
 
#define N_(String)   gettext_noop (String)
 

Functions

std::string translation::dgettext (const char *domain, const char *msgid)
 
std::string translation::egettext (char const *msgid)
 
std::string translation::dsgettext (const char *domainname, const char *msgid)
 
std::string translation::dsngettext (const char *domainname, const char *singular, const char *plural, int n)
 
static UNUSEDNOWARN std::string translation::gettext (const char *str)
 
static UNUSEDNOWARN std::string translation::sgettext (const char *str)
 
static UNUSEDNOWARN std::string translation::sngettext (const char *str1, const char *str2, int n)
 
void translation::bind_textdomain (const char *domain, const char *directory, const char *)
 
void translation::set_default_textdomain (const char *domain)
 
void translation::set_language (const std::string &language, const std::vector< std::string > *)
 
int translation::compare (const std::string &s1, const std::string &s2)
 Case-sensitive lexicographical comparison. More...
 
int translation::icompare (const std::string &s1, const std::string &s2)
 Case-insensitive lexicographical comparison. More...
 
std::string translation::strftime (const std::string &format, const std::tm *time)
 
bool translation::ci_search (const std::string &s1, const std::string &s2)
 
static UNUSEDNOWARN std::string _ (const char *str)
 
static UNUSEDNOWARN std::string _n (const char *str1, const char *str2, int n)
 

Macro Definition Documentation

◆ GETTEXT_DOMAIN

#define GETTEXT_DOMAIN   PACKAGE

How to use gettext for wesnoth source files:

  1. include this header file in the .cpp file
  2. make sure, that the source file is listed in the respective POTFILES.in for the textdomain, in the case of wesnoth-lib it is this file: po/wesnoth-lib/POTFILES.in
  3. add the following include to set the correct textdomain, in this example wesnoth-lib (not required for the domain 'wesnoth', required for all other textdomains).

#define GETTEXT_DOMAIN "wesnoth-lib"

This should be all that is required to have your strings that are marked translatable in the po files and translated ingame. So you at least have to mark the strings translatable, too. ;)

Definition at line 42 of file gettext.hpp.

Referenced by _(), _n(), translation::gettext(), translation::sgettext(), and translation::sngettext().

◆ gettext_noop

#define gettext_noop (   String)    String

Definition at line 98 of file gettext.hpp.

◆ N_

#define N_ (   String)    gettext_noop (String)

◆ UNUSEDNOWARN

#define UNUSEDNOWARN

Definition at line 55 of file gettext.hpp.

Function Documentation

◆ _()

static UNUSEDNOWARN std::string _ ( const char *  str)
inlinestatic

Definition at line 91 of file gettext.hpp.

References translation::dsgettext(), and GETTEXT_DOMAIN.

Referenced by ad_hoc_addon_fetch_session(), gui2::dialogs::statistics_dialog::add_damage_row(), gui2::dialogs::preferences_dialog::add_friend_list_entry(), gui2::dialogs::statistics_dialog::add_hits_row(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), editor::location_palette::adjust_size(), editor::context_manager::apply_mask_dialog(), attack_info(), savegame::autosave_savegame::autosave_savegame(), help::best_str(), gui2::dialogs::chat_log::view::bind(), gui2::dialogs::gamestate_inspector::controller::bind(), gui2::dialogs::lua_interpreter::controller::bind(), BOOST_AUTO_TEST_CASE(), theme::border_t::border_t(), gui2::implementation::builder_slider::build(), gui2::builder_grid::builder_grid(), gui2::implementation::builder_grid_listbox::builder_grid_listbox(), gui2::implementation::builder_horizontal_listbox::builder_horizontal_listbox(), gui2::implementation::builder_listbox::builder_listbox(), gui2::implementation::builder_multi_page::builder_multi_page(), gui2::implementation::builder_pane::builder_pane(), gui2::implementation::builder_panel::builder_panel(), gui2::implementation::builder_scrollbar_panel::builder_scrollbar_panel(), gui2::implementation::builder_size_lock::builder_size_lock(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), gui2::implementation::builder_styled_widget::builder_styled_widget(), gui2::implementation::builder_toggle_panel::builder_toggle_panel(), gui2::implementation::builder_tree_view::builder_tree_view(), gui2::size_lock::calculate_best_size(), events::menu_handler::can_recruit(), events::chat_handler::change_logging(), savegame::savegame::check_filename(), savegame::savegame::check_overwrite(), mp::check_response(), editor::context_manager::check_switch_open_map(), savegame::loadgame::check_version_compatibility(), battle_context::choose_defender_weapon(), gui2::dialogs::game_cache_options::clean_cache_callback(), savegame::clean_saves(), events::menu_handler::clear_labels(), game_config::color_info(), events::map_command_handler< chat_command_handler >::command_failed(), editor::context_manager::confirm_discard(), gui2::dialogs::file_dialog::confirm_overwrite(), ng::connect_engine::connect_engine(), gui2::dialogs::controller_name(), pathfind::shortest_path_calculator::cost(), savegame::ingame_savegame::create_initial_filename(), savegame::replay_savegame::create_initial_filename(), savegame::autosave_savegame::create_initial_filename(), editor::context_manager::create_mask_to_dialog(), default_map_generator::create_scenario(), windows_tray_notification::create_tray_icon(), editor::editor_controller::custom_tods_dialog(), default_map_generator_job::default_generate_map(), gui2::dialogs::preferences_dialog::default_hotkey_callback(), quit_confirmation::default_prompt(), gui2::default_status_value_getter(), gui2::dialogs::addon_manager::delete_addon(), savegame::save_index_class::delete_old_auto_saves(), gui2::dialogs::depcheck_select_new::depcheck_select_new(), gui2::addon_list::describe_status(), gui2::dialogs::describe_status_verbose(), mp_sync::user_choice::description(), persist_choice::description(), ng::user_map::description(), gui2::dialogs::mp_create_game::dialog_exit_hook(), gui2::image_shape::dimension_validation(), gui2::dialogs::unit_recall::dismiss_unit(), events::map_command_handler< chat_command_handler >::dispatch(), gui2::dialogs::lua_interpreter::display(), gui2::dialogs::game_load::display_savegame(), addon_info::display_type(), addons_client::do_check_before_overwriting_addon(), events::console_handler::do_choose_level(), events::console_handler::do_create(), events::console_handler::do_debug(), events::chat_command_handler::do_friend(), playmp_controller::do_idle_notification(), events::chat_command_handler::do_ignore(), events::chat_command_handler::do_info(), events::console_handler::do_nodebug(), events::chat_command_handler::do_remove(), addons_client::do_resolve_addon_dependencies(), events::console_handler::do_set_var(), events::console_handler::do_toggle_whiteboard(), events::console_handler::do_undiscover(), events::console_handler::do_unsafe_lua(), events::chat_command_handler::do_version(), gui2::line_shape::draw(), gui2::rectangle_shape::draw(), gui2::round_rectangle_shape::draw(), gui2::circle_shape::draw(), gui2::text_shape::draw(), editor::editor_palette< overlay >::draw_contents(), events::menu_handler::end_turn(), sp::enter_create_mode(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::game_load::evaluate_summary_string(), gui2::dialogs::game_stats::execute(), gui2::dialogs::unit_list::execute(), gui2::dialogs::addon_manager::execute_action_on_selected_addon(), hotkey::command_executor::execute_command_wrap(), gui2::dialogs::addon_manager::execute_default_action(), editor::context_manager::expand_areas_menu(), play_controller::hotkey_handler::expand_autosaves(), editor::context_manager::expand_load_mru_menu(), editor::editor_palette< overlay >::expand_palette_groups_menu(), editor::context_manager::expand_sides_menu(), gui2::dialogs::addon_manager::fetch_addons_list(), actions::find_recall_location(), actions::find_recruit_location(), savegame::savegame::finish_save_game(), savegame::save_info::format_time_local(), utils::format_time_summary(), utils::format_timespan(), mp_ui_alerts::game_created(), mp_ui_alerts::game_has_begun(), mp::game_info::game_info(), help::generate_ability_topics(), help::generate_era_topics(), help::generate_faction_topics(), editor::context_manager::generate_map_dialog(), help::generate_races_sections(), gui2::dialogs::mp_join_game::generate_side_list(), help::generate_time_of_day_topics(), help::generate_trait_topics(), help::generate_unit_topics(), gui2::dialogs::generate_user_description(), help::generate_weapon_special_topics(), preferences::get_chat_timestamp(), font::get_color_string_pango(), events::chat_command_handler::get_command_flags_description(), events::console_handler::get_command_flags_description(), editor::map_context::get_default_context_name(), game_config::get_default_title_string(), events::chat_command_handler::get_flags_description(), events::console_handler::get_flags_description(), gui2::dialogs::preferences_dialog::get_friends_list_row_data(), editor::terrain_palette::get_help_string(), gui2::get_hp_tooltip(), filesystem::get_localized_path(), gui2::get_mp_tooltip(), help::help_browser::handle_event(), events::map_command_handler< chat_command_handler >::help(), events::map_command_handler< chat_command_handler >::help_command(), gui2::dialogs::title_screen::hotkey_callback_select_tests(), gui2::init(), gui2::dialogs::player_list::init(), play_controller::init(), ng::create_engine::init_all_levels(), events::chat_command_handler::init_map(), events::console_handler::init_map(), events::map_command_handler< chat_command_handler >::init_map_default(), intf_synchronize_choice(), intf_synchronize_choices(), gui2::dialogs::label_settings::label_settings(), game_launcher::launch_game(), gui2::window::layout(), playmp_controller::linger(), gui2::dialogs::addon_manager::load_addon_list(), playsingle_controller::hotkey_handler::load_autosave(), game_launcher::load_game(), savegame::loadgame::load_game(), game_config_manager::load_game_config(), savegame::loadgame::load_game_ingame(), editor::context_manager::load_map(), editor::context_manager::load_map_dialog(), savegame::loadgame::load_multiplayer_game(), gui2::dialogs::mp_lobby::logout_prompt(), editor::editor_controller::main_loop(), ng::depcheck::MAKE_ENUM(), gui2::dialogs::make_screenshot(), editor::map_context::map_context(), hotkey::command_executor_default::map_screenshot(), ng::scenario::map_size(), editor::editor_map::mask_to(), editor::mouse_action_unit::move(), events::mouse_handler::move_unit_along_route(), gui2::dialogs::mp_create_game::mp_create_game(), gui2::dialogs::mp_join_game::network_handler(), ng::side_engine::new_config(), editor::context_manager::new_map_dialog(), editor::context_manager::new_scenario_dialog(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::faction_select::on_faction_select(), gui2::dialogs::file_dialog::on_file_delete_cmd(), gui2::dialogs::mp_create_game::on_game_select(), gui2::dialogs::mp_connect::on_server_add(), gui2::dialogs::game_stats::on_tab_select(), help::terrain_topic_generator::operator()(), help::unit_topic_generator::operator()(), savegame::save_info_less_time::operator()(), game_config::optional_features_table(), wb::manager::options_dlg(), desktop::os_version(), gui2::dialogs::outro::outro(), gui2::implementation::parse_list_data(), campaign_controller::play_game(), playmp_controller::play_human_turn(), game_launcher::play_multiplayer(), playsingle_controller::play_scenario(), playsingle_controller::play_scenario_init(), mp_ui_alerts::player_joins(), mp_ui_alerts::player_leaves(), gui2::dialogs::mp_lobby::post_build(), gui2::dialogs::mp_create_game::post_show(), gui2::dialogs::generator_settings::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::custom_tod::pre_show(), gui2::dialogs::editor_set_starting_position::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::screenshot_notification::pre_show(), gui2::dialogs::mp_staging::pre_show(), gui2::dialogs::folder_create::pre_show(), gui2::dialogs::game_cache_options::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::preferences_dialog::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::unit_preview_pane::print_attack_details(), gui2::dialogs::network_transmission::pump_monitor::process(), turn_info::process_network_data(), playmp_controller::process_oos(), play_controller::process_oos(), gui2::dialogs::addon_manager::publish_addon(), gui2::dialogs::game_cache_options::purge_cache_callback(), game_events::wml_event_pump::put_wml_message(), editor::editor_controller::quit_confirm(), gui2::builder_window::read(), mp_ui_alerts::ready_for_start(), events::menu_handler::recall(), wesnothd_connection::receive_data(), events::menu_handler::recruit(), gui2::dialogs::preferences_dialog::remove_friend_list_entry(), gui2::dialogs::preferences_dialog::remove_hotkey_callback(), gui2::dialogs::unit_recall::rename_unit(), events::menu_handler::rename_unit(), REPORT_GENERATOR(), campaign_controller::report_victory(), addons_client::request_addons_list(), addons_client::request_distribution_terms(), gui2::scrollbar_panel_definition::resolution::resolution(), gui2::size_lock_definition::resolution::resolution(), gui2::unit_preview_pane_definition::resolution::resolution(), gui2::scroll_label_definition::resolution::resolution(), gui2::stacked_widget_definition::resolution::resolution(), gui2::tree_view_definition::resolution::resolution(), gui2::addon_list_definition::resolution::resolution(), gui2::multi_page_definition::resolution::resolution(), gui2::chatbox_definition::resolution::resolution(), gui2::listbox_definition::resolution::resolution(), ng::flg_manager::resolve_random(), savegame::savegame::save_game(), events::menu_handler::save_map(), editor::map_context::save_map(), editor::context_manager::save_map_as(), editor::context_manager::save_map_as_dialog(), editor::context_manager::save_scenario_as(), editor::context_manager::save_scenario_as_dialog(), gui2::dialogs::screenshot_notification::save_screenshot(), events::menu_handler::search(), gui2::dialogs::custom_tod::select_file(), desktop::notifications::send(), gui2::addon_list::set_addons(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), font::pango_text::set_markup(), ng::scenario::set_metadata(), gui2::dialogs::game_load::set_save_dir_list(), filesystem::set_user_data_dir(), gui2::multimenu_button::set_values(), gui2::dialogs::preferences_dialog::setup_hotkey_list(), wml_exception::show(), events::mouse_handler::show_attack_dialog(), campaign_controller::show_carryover_message(), gui2::dialogs::mp_create_game::show_description(), gui2::show_error_message(), help::show_help(), gui2::show_message(), play_controller::show_objectives(), quit_confirmation::show_prompt(), preferences::show_theme_dialog(), gui2::show_transient_error_message(), playsingle_controller::show_turn_dialog(), preferences::show_wesnothd_server_search(), utils::si_string(), gui2::label::signal_handler_left_button_click(), gui2::label::signal_handler_right_button_click(), size_display_string(), events::menu_handler::speak(), help::split_in_width(), gui2::state_definition::state_definition(), t_translation::string_to_layer_(), gui2::styled_widget_definition::styled_widget_definition(), hotkey::command_executor::surrender_game(), SYNCED_COMMAND_HANDLER_FUNCTION(), gui2::dialogs::tally(), terrain_type::terrain_type(), gui2::text_shape::text_shape(), time_of_day_at(), tod_stats_at(), play_controller::hotkey_handler::toggle_accelerated_speed(), gui2::dialogs::addon_manager::toggle_details(), theme::action::tooltip(), gui2::implementation::tree_node::tree_node(), gui2::tree_view_node::tree_view_node(), addons_client::try_fetch_addon(), mp_ui_alerts::turn_changed(), gui2::dialogs::addon_manager::uninstall_addon(), unit_abilities(), unit_alignment(), unit_box_at(), unit_defense(), unit_type::unit_description(), unit_hp(), unit_level(), unit_moves(), unit_name(), unit_race(), unit_traits(), unit_type(), unit_vision(), unit_weapons(), unit_xp(), gui2::dialogs::game_cache_options::update_cache_size_display(), ng::side_engine::update_controller_options(), gui2::multimenu_button::update_label(), gui2::dialogs::mp_staging::update_leader_display(), gui2::dialogs::statistics_dialog::update_lists(), gui2::dialogs::lobby_player_info::update_relation(), gui2::dialogs::mp_staging::update_status_label_and_buttons(), addons_client::wait_for_transfer_done(), playsingle_controller::hotkey_handler::whiteboard_toggle(), gui2::builder_window::window_resolution::window_resolution(), gui2::dialogs::wml_error::wml_error(), font::word_wrap_text(), savegame::ingame_savegame::write_game(), savegame::savegame::write_game_to_disk(), editor::context_manager::write_map(), editor::context_manager::write_scenario(), and map_location::write_translated_direction().

◆ _n()

static UNUSEDNOWARN std::string _n ( const char *  str1,
const char *  str2,
int  n 
)
inlinestatic