描述
很多时候,在两个以上的地方发现的类似可翻译文本会发生冲突,但翻译上下文不同。
通过在pot文件中包含上下文,翻译人员可以不同地翻译这两个字符串。
参数
- $text
-
(string)(必填) 要翻译的文本。
- $context
-
(string)(必填) 翻译人员的上下文信息。
- $domain
-
(string)(可选) 文本域。检索已翻译字符串的唯一标识符。
默认值: 'default'
返回
(string) 翻译后的上下文字符串。
相关
| 使用 | 描述 |
|---|---|
| translate_with_gettext_context() |
| 被使用 | 描述 |
|---|---|
| the_meta() | 显示文章自定义字段的列表 |
| get_the_posts_pagination() | 检索文章的下一页/上一页分页导航(如适用) |
| post_tags_meta_box() | 显示文章标签表单字段 |
| _ex() | 使用gettext上下文显示翻译后的字符串 |
| wp_trim_excerpt() | 如果需要,从内容中生成摘录 |
| wp_trim_words() | 将文本修剪为一定数量的单词 |
| get_calendar() | 显示有文章的日期(作为链接)的日历 |
| get_search_form() | 显示搜索表单 |
| wp_insert_user() | 将用户插入数据库 |
| wp_dropdown_users() | 创建用户的下拉HTML内容 |
| comment_form() | 输出完整的评论表单,供在模板中使用 |
| comment_type() | 显示当前评论的评论类型 |
| wp_default_styles() | 为$styles对象指定默认样式 |
| WP_Widget_Media::get_l10n_defaults() | |
| WP_Taxonomy::get_default_labels() | |
| WP_Post_Type::get_default_labels() | |
| get_default_block_template_types() | |
| get_default_block_categories() | |
| wpmu_new_site_admin_notification() | |
| _register_core_block_patterns_and_categories() | |
| validate_theme_requirements() | |
| Plugin_Installer_Skin::do_overwrite() | |
| Theme_Installer_Skin::do_overwrite() | |
| wp_credits_section_title() | |
| get_post_states() | |
| WP_Debug_Data::debug_data() | |
| validate_plugin_requirements() | |
| wp_get_default_update_php_url() | |
| taxonomy_meta_box_sanitize_cb_input() | |
| wp_default_packages_scripts() | |
| register_and_do_post_meta_boxes() | |
| _wp_privacy_statuses() | |
| wp_privacy_generate_personal_data_export_file() | |
| WP_Widget_Media_Gallery::__construct() | |
| WP_Customize_Nav_Menu_Locations_Control::content_template() | |
| WP_Widget_Media_Audio::__construct() | |
| WP_Widget_Media_Video::__construct() | |
| WP_Widget_Media_Image::__construct() | |
| wp_dashboard_events_news() | |
| WP_Community_Events::format_event_data_time() | |
| get_theme_starter_content() | |
| _WP_Editors::get_translation() | |
| wp_print_update_row_templates() | |
| WP_Customize_Manager::customize_pane_settings() | |
| wp_get_document_title() | |
| wp_maybe_decline_date() | |
| WP_Screen::render_meta_boxes_preferences() | |
| WP_Users_List_Table::get_role_list() | |
| WP_Customize_Nav_Menu_Setting::sanitize() | |
| WP_Customize_Nav_Menus::search_available_items_query() | |
| WP_Customize_Nav_Menus::enqueue_scripts() | |
| WP_Customize_Nav_Menus::customize_register() | |
| WP_Customize_Nav_Menus::load_available_items_query() | |
| WP_Posts_List_Table::handle_row_actions() | |
| WP_MS_Themes_List_Table::column_name() | |
| WP_Comments_List_Table::handle_row_actions() | |
| WP_MS_Sites_List_Table::handle_row_actions() | |
| WP_MS_Users_List_Table::column_name() | |
| WP_Customize_Theme_Control::content_template() | |
| customize_themes_print_templates() | |
| wp_install_maybe_enable_pretty_permalinks() | |
| get_the_archive_title() | |
| wp_dropdown_languages() | |
| get_comments_number_text() | |
| login_footer() | |
| network_step1() | |
| WP_MS_Users_List_Table::get_bulk_actions() | |
| WP_MS_Users_List_Table::get_columns() | |
| get_theme_update_available() | |
| WP_Plugins_List_Table::single_row() | |
| WP_Links_List_Table::get_columns() | |
| Theme_Upgrader_Skin::after() | |
| Theme_Installer_Skin::after() | |
| WP_List_Table::pagination() | |
| WP_Theme_Install_List_Table::install_theme_info() | |
| populate_options() | |
| WP_Theme_Install_List_Table::prepare_items() | |
| WP_Theme_Install_List_Table::single_row() | |
| wp_plugin_update_row() | |
| wp_theme_update_row() | |
| install_plugin_information() | |
| wp_dashboard_recent_posts() | |
| wp_dashboard_plugins_output() | |
| wp_dashboard_recent_drafts() | |
| _wp_dashboard_recent_comments_row() | |
| wp_install_defaults() | |
| WP_Plugin_Install_List_Table::display_rows() | |
| WP_Plugin_Install_List_Table::prepare_items() | |
| list_meta() | |
| WP_Themes_List_Table::display_rows() | |
| WP_MS_Sites_List_Table::__construct() | |
| WP_MS_Sites_List_Table::get_bulk_actions() | |
| WP_MS_Sites_List_Table::get_columns() | |
| WP_Users_List_Table::single_row() | |
| WP_Users_List_Table::get_columns() | |
| bulk_edit_posts() | |
| wp_prepare_revisions_for_js() | |
| wp_ajax_ajax_tag_search() | |
| wp_ajax_autocomplete_user() | |
| post_submit_meta_box() | |
| attachment_submit_meta_box() | |
| WP_Media_List_Table::get_views() | |
| WP_Media_List_Table::get_columns() | |
| WP_Media_List_Table::_get_row_actions() | |
| WP_Post_Comments_List_Table::get_column_info() | |
| WP_Comments_List_Table::get_bulk_actions() | |
| WP_Comments_List_Table::get_columns() | |
| WP_Terms_List_Table::get_columns() | |
| wp_nav_menu_item_post_type_meta_box() | |
| WP_Posts_List_Table::get_columns() | |
| Custom_Image_Header::step_1() | |
| WP_Customize_Manager::register_controls() | |
| capital_P_dangit() | |
| wptexturize() | |
| register_admin_color_schemes() | |
| feed_links() | |
| feed_links_extra() | |
| WP_Theme::translate_header() | |
| WP_Query::get_search_stopwords() | |
| size_format() | |
| WP_Widget_Recent_Comments::widget() | |
| WP_Widget_Search::__construct() | |
| WP_Locale::init() | |
| create_initial_taxonomies() | |
| wp_admin_bar_new_content_menu() | |
| wp_post_revision_title() | |
| wp_post_revision_title_expanded() | |
| wp_enqueue_media() | |
| wp_underscore_playlist_templates() | |
| wp_get_attachment_id3_keys() | |
| wp_set_post_terms() | |
| get_post_mime_types() | |
| create_initial_post_types() | |
| wpmu_signup_blog_notification() | |
| wpmu_signup_user_notification() | |
| get_post_format_strings() | |
| get_comment_excerpt() | |
| WP_Customize_Widgets::enqueue_scripts() | |
| wp_just_in_time_script_localization() | |
| wp_default_scripts() | |
| get_comment_statuses() | |
| _WP_Editors::editor() |
源码
更新日志
| 版本 | 描述 |
|---|---|
| 2.8.0 | 开始引入 |
使用示例
- 示例1
实例
$translated = _x( 'Read', 'past participle: books I have read', 'textdomain' );
由于字符串“Read”本身在英语中可能有几种不同的含义,因此给出了上下文,以便译者知道他们应该提供一个简短的术语,意思是“我读过的书”