Go to the source code of this file.
Namespaces | |
utils | |
utils::detail | |
Macros | |
#define | VGETTEXT(msgid, ...) vgettext_impl(GETTEXT_DOMAIN, msgid, __VA_ARGS__) |
Handy wrappers around interpolate_variables_into_string and gettext. More... | |
#define | VNGETTEXT(msgid, msgid_plural, count, ...) vngettext_impl(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__) |
Functions | |
bool | utils::might_contain_variables (const std::string &str) |
Determines if a string might contain variables to interpolate. More... | |
std::string | utils::interpolate_variables_into_string (const std::string &str, const std::map< std::string, t_string > *const symbols) |
Function which will interpolate variables, starting with '$' in the string 'str' with the equivalent symbols in the given symbol table. More... | |
std::string | utils::interpolate_variables_into_string (const std::string &str, const std::map< std::string, std::string > *const symbols) |
std::string | utils::interpolate_variables_into_string (const std::string &str, const variable_set &variables) |
t_string | utils::interpolate_variables_into_tstring (const t_string &str, const variable_set &variables) |
Function that does the same as the above, for t_stringS. More... | |
std::string | utils::format_conjunct_list (const t_string &empty, const std::vector< t_string > &elems) |
Format a conjunctive list. More... | |
std::string | utils::format_disjunct_list (const t_string &empty, const std::vector< t_string > &elems) |
Format a disjunctive list. More... | |
std::string | utils::format_timespan (std::time_t time, bool detailed=false) |
Formats a timespan into human-readable text for player authentication functions. More... | |
std::string | vgettext_impl (const char *domain, const char *msgid, const utils::string_map &symbols) |
Implementation functions for the VGETTEXT and VNGETTEXT macros. More... | |
std::string | vngettext_impl (const char *domain, const char *singular, const char *plural, int count, const utils::string_map &symbols) |
int | edit_distance_approx (const std::string &str_1, const std::string &str_2) |
Approximately calculates the distance between two strings. More... | |
#define VGETTEXT | ( | msgid, | |
... | |||
) | vgettext_impl(GETTEXT_DOMAIN, msgid, __VA_ARGS__) |
Handy wrappers around interpolate_variables_into_string and gettext.
These should cover most usecases. If you're not sure whether you want these macros or their implementation functions, use these. The only time you should need to use the implementation functions directly is to pass a different textdomain than the current value of GETTEXT_DOMAIN.
Definition at line 127 of file string_utils.hpp.
Referenced by ad_hoc_addon_fetch_session(), gui2::dialogs::preferences_dialog::add_hotkey_callback(), unit::add_modification(), events::chat_handler::add_whisper_received(), events::chat_handler::add_whisper_sent(), gui2::chatbox::add_whisper_sent(), gui2::builder_grid::builder_grid(), events::menu_handler::can_recruit(), events::chat_handler::change_logging(), mp::game_info::check_addon_version_compatibility(), events::map_command_handler< chat_command_handler >::command_failed_need_arg(), addons_client::connect(), gui2::dialogs::addon_manager::delete_addon(), addons_client::delete_remote_addon(), gui2::dialogs::depcheck_confirm_change::depcheck_confirm_change(), deprecate_wml_key_warning(), deprecated_message(), deprecated_renamed_wml_key_warning(), unit::describe_builtin_effect(), attack_type::describe_modification(), events::map_command_handler< chat_command_handler >::dispatch(), gui2::dialogs::game_load::display_savegame_internal(), addons_client::do_check_before_overwriting_addon(), events::console_handler::do_control(), events::console_handler::do_controller(), events::console_handler::do_droid(), events::chat_command_handler::do_friend(), events::console_handler::do_idle(), events::chat_command_handler::do_ignore(), events::chat_command_handler::do_info(), events::chat_command_handler::do_remove(), events::menu_handler::do_search(), events::console_handler::do_unit(), addons_client::download_addon(), gui2::dialogs::game_load::evaluate_summary_string(), gui2::dialogs::addon_manager::execute_default_action(), gui2::window::finish_build(), utils::format_conjunct_list(), utils::format_disjunct_list(), mp::ui_alerts::game_created(), mp::game_info::game_info(), ng::configure_engine::game_name_default(), help::generate_unit_topics(), gui2::dialogs::generate_user_description(), team::get_side_color_name_for_UI(), events::map_command_handler< chat_command_handler >::help(), gui2::dialogs::title_screen::init_callbacks(), mp::initial_level_config(), addons_client::install_addon(), gui2::dialogs::label_settings::label_settings(), game_config_manager::load_addons_cfg(), editor::context_manager::load_map(), gui2::dialogs::mp_lobby::make_game_row_data(), missing_mandatory_wml_key(), gui2::missing_widget(), gui2::dialogs::mp_match_history::mp_match_history(), ng::side_engine::new_config(), gui2::dialogs::file_dialog::on_dir_create_cmd(), gui2::dialogs::file_dialog::on_file_delete_cmd(), gui2::dialogs::statistics_dialog::on_primary_list_select(), wb::manager::options_dlg(), gui2::parse_linked_group_definitions(), gui2::dialogs::mp_change_control::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::addon_manager::pre_show(), turn_info::process_network_data(), gui2::dialogs::file_dialog::process_submit_common(), ng::flg_manager::resolve_random(), gui2::chatbox::room_window_open(), events::menu_handler::save_map(), editor::map_context::save_map(), editor::map_context::save_scenario(), gui2::unit_preview_pane::set_displayed_type(), gui2::unit_preview_pane::set_displayed_unit(), location_palette_item::set_item_id(), gui2::dialogs::game_load::set_save_dir_list(), editor::editor_map::set_starting_position_labels(), preferences::show_wesnothd_server_search(), side_tooltip(), SYNCED_COMMAND_HANDLER_FUNCTION(), utils::irdya_date::to_string(), play_controller::hotkey_handler::toggle_accelerated_speed(), mp::ui_alerts::turn_changed(), unit_weapons(), gui2::dialogs::mp_create_game::update_details(), gui2::dialogs::mp_lobby::update_visible_games(), addons_client::upload_addon(), gui2::chatbox::whisper_window_open(), playsingle_controller::hotkey_handler::whiteboard_toggle(), and editor::wrap_exc().
#define VNGETTEXT | ( | msgid, | |
msgid_plural, | |||
count, | |||
... | |||
) | vngettext_impl(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__) |
Definition at line 130 of file string_utils.hpp.
Referenced by unit::describe_builtin_effect(), attack_type::describe_modification(), utils::format_timespan(), help::terrain_topic_generator::operator()(), events::menu_handler::recall(), events::menu_handler::recruit(), campaign_controller::show_carryover_message(), gui2::multimenu_button::update_label(), and user_choice_manager::update_local_choice().
int edit_distance_approx | ( | const std::string & | str_1, |
const std::string & | str_2 | ||
) |
Approximately calculates the distance between two strings.
Inspired in the Levenshtein distance, but made simpler to avoid using recursion and wasting resources.
The consequence is that the function gets "lost" after two consecutive differences.
str_1 | First string to compare |
str_2 | Second string to compare |
Definition at line 360 of file string_utils.cpp.
References i.
Referenced by events::map_command_handler< chat_command_handler >::dispatch().
std::string vgettext_impl | ( | const char * | domain, |
const char * | msgid, | ||
const utils::string_map & | symbols | ||
) |
Implementation functions for the VGETTEXT and VNGETTEXT macros.
DO NOT USE DIRECTLY unless you really know what you're doing. See https://github.com/wesnoth/wesnoth/issues/2716 for more info.
Definition at line 340 of file string_utils.cpp.
References translation::dsgettext(), utils::interpolate_variables_into_string(), and wfl::msg().
Referenced by utils::might_contain_variables().
std::string vngettext_impl | ( | const char * | domain, |
const char * | singular, | ||
const char * | plural, | ||
int | count, | ||
const utils::string_map & | symbols | ||
) |
Definition at line 349 of file string_utils.cpp.
References translation::dsngettext(), utils::interpolate_variables_into_string(), and wfl::msg().
Referenced by utils::might_contain_variables().