The Battle for Wesnoth  1.19.7+dev
Namespaces | Macros | Functions
gettext.hpp File Reference
#include "wesconfig.h"
#include <string>
#include <vector>
#include <ctime>
#include <boost/locale/info.hpp>
Include dependency graph for gettext.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 translation
 

Macros

#define GETTEXT_DOMAIN   PACKAGE
 How to use gettext for wesnoth source files: More...
 
#define gettext_noop(String)   String
 
#define N_(String)   gettext_noop (String)
 
#define N_n(String1, String2)   String1, String2
 

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 std::string translation::gettext (const char *str)
 
static std::string translation::sgettext (const char *str)
 
static 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)
 
const boost::locale::info & translation::get_effective_locale_info ()
 A facet that holds general information about the effective locale. More...
 
static std::string _ (const char *str)
 
static 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 44 of file gettext.hpp.

◆ gettext_noop

#define gettext_noop (   String)    String

Definition at line 100 of file gettext.hpp.

◆ N_

#define N_ (   String)    gettext_noop (String)

Definition at line 101 of file gettext.hpp.

◆ N_n

#define N_n (   String1,
  String2 
)    String1, String2

Definition at line 102 of file gettext.hpp.

Function Documentation

◆ _()

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

Definition at line 93 of file gettext.hpp.

References translation::dsgettext(), and GETTEXT_DOMAIN.

Referenced by unit::ability_tooltips(), 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_staging::add_side_node(), replay::add_start_if_not_there_yet(), gui2::dialogs::mp_lobby::adjust_game_row_contents(), editor::location_palette::adjust_size(), unit_type::alignment_description(), editor::context_manager::apply_mask_dialog(), attack_info(), savegame::autosave_savegame::autosave_savegame(), help::best_str(), BOOST_AUTO_TEST_CASE(), theme::border_t::border_t(), gui2::implementation::builder_slider::build(), game_config::build_arch(), gui2::implementation::builder_listbox_base::builder_listbox_base(), 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(), gui2::dialogs::campaign_selection::campaign_selected(), events::menu_handler::can_recruit(), ng::depcheck::manager::change_era(), events::chat_handler::change_logging(), ng::depcheck::manager::change_modifications(), ng::depcheck::manager::change_scenario(), gui2::dialogs::file_dialog::check_filename(), savegame::savegame::check_filename(), play_controller::check_next_scenario_is_known(), savegame::savegame::check_overwrite(), 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< Worker >::command_failed(), movetype::terrain_info::data::config_has_changes(), 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(), ng::user_map::description(), persist_choice::description(), mp_sync::user_choice::description(), gui2::dialogs::mp_create_game::dialog_exit_hook(), gui2::image_shape::dimension_validation(), gui2::dialogs::unit_recall::dismiss_unit(), events::map_command_handler< Worker >::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::console_handler::do_droid(), playsingle_controller::do_end_level(), editor::editor_controller::do_execute_command(), events::chat_command_handler::do_friend(), do_gameloop(), 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(), do_replay_handle(), 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(), network::download(), events::menu_handler::end_turn(), gui2::dialogs::mp_lobby::enter_game(), gui2::dialogs::game_load::evaluate_summary_string(), gui2::dialogs::migrate_version_selection::execute(), gui2::dialogs::game_load::execute(), 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(), editor::context_manager::expand_load_mru_menu(), editor::editor_palette< Item >::expand_palette_groups_menu(), editor::context_manager::expand_sides_menu(), ng::depcheck::manager::failure_dialog(), gui2::dialogs::addon_manager::fetch_addons_list(), schema_validation::schema_validator::find_mandatory_keys(), actions::find_recall_location(), actions::find_recruit_location(), savegame::savegame::finish_save_game(), gui2::dialogs::format_addon_time(), savegame::save_info::format_time_local(), utils::format_time_summary(), utils::format_timespan(), utils::from_chars(), 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(), gui2::listbox::get_active_sorter(), prefs::get_chat_timestamp(), events::console_handler::get_command_flags_description(), events::chat_command_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(), wfl::config_callable::get_inputs(), filesystem::get_localized_path(), gui2::get_mp_tooltip(), vconfig::get_parsed_config(), gui2::rich_label::get_parsed_text(), get_replay_action_type(), wfl::attack_type_callable::get_value(), handle_preprocess_command(), handle_preprocess_string(), events::map_command_handler< Worker >::help(), events::map_command_handler< Worker >::help_command(), gui2::dialogs::title_screen::hotkey_callback_select_tests(), gui2::init(), play_controller::init(), gui2::lobby_player_list_helper::init(), ng::create_engine::init_all_levels(), events::chat_command_handler::init_map(), events::console_handler::init_map(), events::map_command_handler< Worker >::init_map_default(), addons_client::install_addon(), intf_synchronize_choice(), intf_synchronize_choices(), lua_wml::intf_wml_merge(), gui2::dialogs::label_settings::label_settings(), game_launcher::launch_game(), editor::editor_palette< Item >::layout(), gui2::window::layout(), gui2::dialogs::unit_create::list_item_clicked(), 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(), gui2::chatbox::load_log(), editor::context_manager::load_map(), editor::context_manager::load_map_dialog(), savegame::loadgame::load_multiplayer_game(), prefs::load_preferences(), gui2::dialogs::editor_edit_unit::load_unit_type(), gui2::dialogs::mp_lobby::logout_prompt(), editor::editor_controller::main_loop(), gui2::dialogs::make_screenshot(), editor::map_context::map_context(), hotkey::command_executor_default::map_screenshot(), ng::scenario::map_size(), gui2::listbox::mark_as_unsorted(), editor::editor_map::mask_to(), editor::mouse_action_unit::move(), events::mouse_handler::move_unit_along_route(), gui2::dialogs::mp_options_helper::mp_options_helper(), 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(), gui2::listbox::order_by_column(), 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::editor_choose_addon::populate_list(), gui2::dialogs::mp_create_game::post_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::campaign_selection::pre_show(), gui2::dialogs::editor_edit_pbl::pre_show(), gui2::dialogs::editor_edit_unit::pre_show(), gui2::dialogs::generator_settings::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::dialogs::folder_create::pre_show(), gui2::dialogs::game_stats::pre_show(), gui2::dialogs::mp_match_history::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::mp_report::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::statistics_dialog::pre_show(), gui2::dialogs::unit_attack::pre_show(), gui2::dialogs::unit_recall::pre_show(), gui2::unit_preview_pane::print_attack_details(), help::print_behavior_description(), gui2::dialogs::network_transmission::pump_monitor::process(), playmp_controller::process_network_side_drop_impl(), 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::dialogs::editor_edit_unit::quit_confirmation(), gui2::builder_window::read(), mp::ui_alerts::ready_for_start(), events::menu_handler::recall(), wesnothd_connection::receive_data(), actions::undo_list::redo(), 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(), gui2::dialogs::game_version::report_issue(), addons_client::request_addons_list(), addons_client::request_distribution_terms(), gui2::dialogs::mp_match_history::request_history(), gui2::addon_list_definition::resolution::resolution(), gui2::multi_page_definition::resolution::resolution(), gui2::size_lock_definition::resolution::resolution(), gui2::stacked_widget_definition::resolution::resolution(), gui2::tab_container_definition::resolution::resolution(), ng::flg_manager::resolve_random(), savegame::savegame::save_game(), editor::map_context::save_map(), events::menu_handler::save_map(), editor::context_manager::save_map_as_dialog(), editor::context_manager::save_scenario_as_dialog(), editor::map_context::save_schedule(), gui2::dialogs::screenshot_notification::save_screenshot(), gui2::dialogs::editor_edit_unit::save_unit_type(), events::menu_handler::search(), sp::select_campaign(), gui2::dialogs::custom_tod::select_file(), gui2::dialogs::editor_edit_unit::select_file(), gui2::dialogs::editor_edit_pbl::select_icon_file(), gui2::dialogs::achievements_dialog::set_achievements_row(), gui2::listbox::set_active_sorter(), gui2::addon_list::set_addons(), gui2::dialogs::attack_predictions::set_data(), gui2::unit_preview_pane::set_display_data(), ng::scenario::set_metadata(), gui2::dialogs::game_load::set_save_dir_list(), gui2::multimenu_button::set_values(), gui2::dialogs::preferences_dialog::setup_hotkey_list(), wml_exception::show(), events::mouse_handler::show_attack_dialog(), show_deprecated_warnings(), gui2::dialogs::mp_create_game::show_description(), gui2::show_error_message(), gui2::dialogs::game_version::show_manual(), gui2::show_message(), play_controller::show_objectives(), quit_confirmation::show_prompt(), prefs::show_theme_dialog(), gui2::show_transient_error_message(), playsingle_controller::show_turn_dialog(), prefs::show_wesnothd_server_search(), utils::si_string(), gui2::label::signal_handler_left_button_click(), gui2::multiline_text::signal_handler_left_button_down(), gui2::label::signal_handler_right_button_click(), size_display_string(), events::menu_handler::speak(), gui2::rich_label::split_in_width(), gui2::styled_widget_definition::styled_widget_definition(), hotkey::command_executor::surrender_game(), gui2::dialogs::tally(), terrain_type::terrain_type(), time_of_day_at(), play_controller::to_config(), tod_stats_at(), play_controller::hotkey_handler::toggle_accelerated_speed(), gui2::dialogs::addon_manager::toggle_details(), theme::action::tooltip(), translated_addon_check_status(), gui2::implementation::tree_node::tree_node(), gui2::tree_view_node::tree_view_node(), addons_client::try_fetch_addon(), mp::ui_alerts::turn_changed(), actions::undo::move_action::undo(), gui2::dialogs::addon_manager::uninstall_addon(), unit_abilities(), unit_alignment(), unit_box_at(), unit_defense(), unit_type::unit_description(), unit_hp(), unit_helper::unit_level_tooltip(), 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::dialogs::mp_match_history::update_display(), 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::upload_addon(), gui2::dialogs::editor_edit_pbl::validate(), addons_client::wait_for_transfer_done(), attack_type::weapon_specials_value(), playsingle_controller::hotkey_handler::whiteboard_toggle(), gui2::builder_window::window_resolution::window_resolution(), gui2::dialogs::wml_error::wml_error(), gui2::dialogs::editor_edit_unit::write(), 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 std::string _n ( const char *  str1,
const char *  str2,
int  n 
)
inlinestatic