返回介绍

_x()

发布于 2017-09-11 13:50:20 字数 11780 浏览 1303 评论 0 收藏 0

_x( string $text,  string $context,  string $domain = 'default' )

Retrieve translated string with gettext context.


description

Quite a few times, there will be collisions with similar translatable text found in more than two places, but with different translated context.

By including the context in the pot file, translators can translate the two strings differently.


参数

$text

(string) (Required) Text to translate.

$context

(string) (Required) Context information for the translators.

$domain

(string) (Optional) Text domain. Unique identifier for retrieving translated strings.

Default value: 'default'


返回值

(string) Translated context string without pipe.


源代码

File: wp-includes/l10n.php

function _x( $text, $context, $domain = 'default' ) {
	return translate_with_gettext_context( $text, $context, $domain );
}

更新日志

Versiondescription
2.8.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: translate_with_gettext_context()

Used By

  • wp-includes/widgets/class-wp-widget-media-audio.php: WP_Widget_Media_Audio::__construct()
  • wp-includes/widgets/class-wp-widget-media-video.php: WP_Widget_Media_Video::__construct()
  • wp-includes/widgets/class-wp-widget-media.php: WP_Widget_Media::__construct()
  • wp-includes/widgets/class-wp-widget-media-image.php: WP_Widget_Media_Image::__construct()
  • wp-includes/theme.php: get_theme_starter_content()
  • wp-includes/class-wp-editor.php: _WP_Editors::get_translation()
  • wp-admin/includes/update.php: wp_print_update_row_templates()
  • wp-includes/general-template.php: wp_get_document_title()
  • wp-includes/functions.php: wp_maybe_decline_date()
  • wp-admin/includes/class-wp-screen.php: WP_Screen::render_meta_boxes_preferences()
  • wp-admin/includes/class-wp-users-list-table.php: WP_Users_List_Table::get_role_list()
  • wp-includes/customize/class-wp-customize-nav-menu-control.php: WP_Customize_Nav_Menu_Control::content_template()
  • wp-includes/customize/class-wp-customize-nav-menu-setting.php: WP_Customize_Nav_Menu_Setting::sanitize()
  • wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::enqueue_scripts()
  • wp-includes/class-wp-customize-nav-menus.php: WP_Customize_Nav_Menus::load_available_items_query()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::handle_row_actions()
  • wp-admin/includes/class-wp-ms-themes-list-table.php: WP_MS_Themes_List_Table::column_name()
  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::handle_row_actions()
  • wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::handle_row_actions()
  • wp-includes/customize/class-wp-customize-theme-control.php: WP_Customize_Theme_Control::content_template()
  • wp-admin/includes/class-wp-press-this.php: WP_Press_This::get_suggested_content()
  • wp-admin/includes/upgrade.php: wp_install_maybe_enable_pretty_permalinks()
  • wp-includes/general-template.php: get_the_archive_title()
  • wp-includes/link-template.php: get_the_posts_pagination()
  • wp-includes/l10n.php: wp_dropdown_languages()
  • wp-includes/comment-template.php: get_comments_number_text()
  • wp-login.php: login_footer()
  • wp-admin/includes/network.php: network_step1()
  • wp-admin/includes/class-wp-ms-users-list-table.php: WP_MS_Users_List_Table::get_bulk_actions()
  • wp-admin/includes/class-wp-ms-users-list-table.php: WP_MS_Users_List_Table::get_columns()
  • wp-admin/includes/class-wp-plugins-list-table.php: WP_Plugins_List_Table::single_row()
  • wp-admin/includes/class-wp-links-list-table.php: WP_Links_List_Table::get_columns()
  • wp-admin/includes/class-wp-list-table.php: WP_List_Table::pagination()
  • wp-admin/includes/schema.php: populate_roles_160()
  • wp-admin/includes/class-wp-theme-install-list-table.php: WP_Theme_Install_List_Table::install_theme_info()
  • wp-admin/includes/schema.php: populate_options()
  • wp-admin/includes/class-wp-theme-install-list-table.php: WP_Theme_Install_List_Table::prepare_items()
  • wp-admin/includes/class-wp-theme-install-list-table.php: WP_Theme_Install_List_Table::single_row()
  • wp-admin/includes/plugin-install.php: install_plugin_information()
  • wp-admin/includes/dashboard.php: wp_dashboard_recent_posts()
  • wp-admin/includes/dashboard.php: wp_dashboard_recent_drafts()
  • wp-admin/includes/dashboard.php: _wp_dashboard_recent_comments_row()
  • wp-admin/includes/upgrade.php: wp_install_defaults()
  • wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::display_rows()
  • wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::prepare_items()
  • wp-admin/includes/template.php: _post_states()
  • wp-admin/includes/template.php: list_meta()
  • wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::__construct()
  • wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::get_bulk_actions()
  • wp-admin/includes/class-wp-ms-sites-list-table.php: WP_MS_Sites_List_Table::get_columns()
  • wp-admin/includes/post.php: edit_post()
  • wp-admin/includes/post.php: bulk_edit_posts()
  • wp-admin/includes/revision.php: wp_prepare_revisions_for_js()
  • wp-admin/includes/ajax-actions.php: wp_ajax_ajax_tag_search()
  • wp-admin/includes/ajax-actions.php: wp_ajax_autocomplete_user()
  • wp-admin/includes/meta-boxes.php: attachment_submit_meta_box()
  • wp-admin/includes/meta-boxes.php: post_tags_meta_box()
  • wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::get_views()
  • wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::get_bulk_actions()
  • wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::get_columns()
  • wp-admin/includes/class-wp-media-list-table.php: WP_Media_List_Table::_get_row_actions()
  • wp-admin/includes/class-wp-post-comments-list-table.php: WP_Post_Comments_List_Table::get_column_info()
  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::get_bulk_actions()
  • wp-admin/includes/class-wp-comments-list-table.php: WP_Comments_List_Table::get_columns()
  • wp-admin/includes/class-wp-terms-list-table.php: WP_Terms_List_Table::get_columns()
  • wp-admin/includes/class-walker-nav-menu-checklist.php: Walker_Nav_Menu_Checklist::start_el()
  • wp-admin/includes/nav-menu.php: wp_nav_menu_item_post_type_meta_box()
  • wp-admin/includes/class-wp-posts-list-table.php: WP_Posts_List_Table::get_columns()
  • wp-admin/custom-header.php: Custom_Image_Header::step_1()
  • wp-admin/menu.php: _add_themes_utility_last()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::register_controls()
  • wp-includes/l10n.php: _ex()
  • wp-includes/formatting.php: capital_P_dangit()
  • wp-includes/formatting.php: wp_trim_words()
  • wp-includes/formatting.php: wptexturize()
  • wp-includes/general-template.php: register_admin_color_schemes()
  • wp-includes/general-template.php: feed_links()
  • wp-includes/general-template.php: feed_links_extra()
  • wp-includes/general-template.php: get_calendar()
  • wp-includes/general-template.php: get_search_form()
  • wp-includes/class-wp-query.php: WP_Query::get_search_stopwords()
  • wp-includes/widgets/class-wp-widget-recent-comments.php: WP_Widget_Recent_Comments::widget()
  • wp-includes/widgets/class-wp-widget-meta.php: WP_Widget_Meta::widget()
  • wp-includes/widgets/class-wp-widget-search.php: WP_Widget_Search::__construct()
  • wp-includes/class-wp-locale.php: WP_Locale::init()
  • wp-includes/taxonomy.php: create_initial_taxonomies()
  • wp-includes/taxonomy.php: get_taxonomy_labels()
  • wp-includes/admin-bar.php: wp_admin_bar_new_content_menu()
  • wp-includes/user.php: wp_insert_user()
  • wp-includes/user.php: wp_dropdown_users()
  • wp-includes/post-template.php: wp_post_revision_title()
  • wp-includes/post-template.php: wp_post_revision_title_expanded()
  • wp-includes/media.php: wp_enqueue_media()
  • wp-includes/media.php: wp_underscore_playlist_templates()
  • wp-includes/media.php: wp_get_attachment_id3_keys()
  • wp-includes/post.php: wp_set_post_terms()
  • wp-includes/post.php: get_post_type_labels()
  • wp-includes/post.php: create_initial_post_types()
  • wp-includes/ms-functions.php: wpmu_signup_blog_notification()
  • wp-includes/ms-functions.php: wpmu_signup_user_notification()
  • wp-includes/post-formats.php: get_post_format_strings()
  • wp-includes/comment-template.php: comment_form()
  • wp-includes/comment-template.php: comment_type()
  • wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::enqueue_scripts()
  • wp-includes/script-loader.php: wp_default_styles()
  • wp-includes/script-loader.php: wp_default_scripts()
  • wp-includes/comment.php: get_comment_statuses()
  • wp-includes/class-wp-editor.php: _WP_Editors::editor()
  • Show 103 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Example

    
    $translated = _x( 'Read', 'past participle: books I have read', 'textdomain' );
    

    Since the string ‘Read’ on its own could have one of several different meanings in English, context is given so that translators know that they should be supplying a short term that means “Books I have read.”

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文