Retrieves 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.
Parameters
$text
stringrequired- Text to translate.
$context
stringrequired- Context information for the translators.
$domain
stringoptional- Text domain. Unique identifier for retrieving translated strings.
Default'default'
.Default:
'default'
Return
string Translated context string without pipe.Source
function _x( $text, $context, $domain = 'default' ) {
return translate_with_gettext_context( $text, $context, $domain );
}
Related
Uses | Description |
---|---|
translate_with_gettext_context()wp-includes/l10n.php | Retrieves the translation of $text in the context defined in $context. |
Used by | Description |
---|---|
_wp_register_default_font_collections()wp-includes/fonts.php | Register the default font collections. |
_register_block_bindings_post_meta_source()wp-includes/block-bindings/post-meta.php | Registers Post Meta source in the block bindings registry. |
_register_block_bindings_pattern_overrides_source()wp-includes/block-bindings/pattern-overrides.php | Registers Pattern Overrides source in the Block Bindings registry. |
WP_Plugin_Dependencies::display_admin_notice_for_circular_dependencies()wp-includes/class-wp-plugin-dependencies.php | Displays an admin notice if circular dependencies are installed. |
wp_get_plugin_action_button()wp-admin/includes/plugin-install.php | Gets the markup for the plugin install action button. |
WP_Navigation_Fallback::create_default_fallback()wp-includes/class-wp-navigation-fallback.php | Creates a default Navigation Block Menu fallback. |
WP_Locale::get_word_count_type()wp-includes/class-wp-locale.php | Retrieves the localized word count type. |
WP_Widget_Media::get_l10n_defaults()wp-includes/widgets/class-wp-widget-media.php | Returns the default localized strings used by the widget. |
WP_Taxonomy::get_default_labels()wp-includes/class-wp-taxonomy.php | Returns the default labels for taxonomies. |
WP_Post_Type::get_default_labels()wp-includes/class-wp-post-type.php | Returns the default labels for post types. |
wp_list_users()wp-includes/user.php | Lists all the users of the site, with several options available. |
get_allowed_block_template_part_areas()wp-includes/block-template-utils.php | Returns a filtered list of allowed area values for template parts. |
get_default_block_template_types()wp-includes/block-template-utils.php | Returns a filtered list of default template types, containing their localized titles and descriptions. |
get_default_block_categories()wp-includes/block-editor.php | Returns the list of default categories for block types. |
wpmu_new_site_admin_notification()wp-includes/ms-functions.php | Notifies the Multisite network administrator that a new site was created. |
_register_core_block_patterns_and_categories()wp-includes/block-patterns.php | Registers the core block patterns and categories. |
validate_theme_requirements()wp-includes/theme.php | Validates the theme requirements for WordPress version and PHP version. |
Plugin_Installer_Skin::do_overwrite()wp-admin/includes/class-plugin-installer-skin.php | Checks if the plugin can be overwritten and outputs the HTML for overwriting a plugin on upload. |
Theme_Installer_Skin::do_overwrite()wp-admin/includes/class-theme-installer-skin.php | Checks if the theme can be overwritten and outputs the HTML for overwriting a theme on upload. |
wp_credits_section_title()wp-admin/includes/credits.php | Displays the title for a given group of contributors. |
get_post_states()wp-admin/includes/template.php | Retrieves an array of post states from a post. |
WP_Debug_Data::debug_data()wp-admin/includes/class-wp-debug-data.php | Static function for generating site debug data when required. |
validate_plugin_requirements()wp-admin/includes/plugin.php | Validates the plugin requirements for WordPress version and PHP version. |
wp_get_default_update_php_url()wp-includes/functions.php | Gets the default URL to learn more about updating the PHP version the site is running on. |
taxonomy_meta_box_sanitize_cb_input()wp-admin/includes/post.php | Sanitizes POST values from an input taxonomy metabox. |
wp_default_packages_scripts()wp-includes/script-loader.php | Registers all the WordPress packages scripts that are in the standardized |
register_and_do_post_meta_boxes()wp-admin/includes/meta-boxes.php | Registers the default post meta boxes, and runs the |
_wp_privacy_statuses()wp-includes/post.php | Returns statuses for privacy requests. |
wp_privacy_generate_personal_data_export_file()wp-admin/includes/privacy-tools.php | Generate the personal data export file. |
WP_Widget_Media_Gallery::__construct()wp-includes/widgets/class-wp-widget-media-gallery.php | Constructor. |
WP_Customize_Nav_Menu_Locations_Control::content_template()wp-includes/customize/class-wp-customize-nav-menu-locations-control.php | JS/Underscore template for the control UI. |
wp_load_press_this()wp-admin/press-this.php | |
WP_Widget_Media_Audio::__construct()wp-includes/widgets/class-wp-widget-media-audio.php | Constructor. |
WP_Widget_Media_Video::__construct()wp-includes/widgets/class-wp-widget-media-video.php | Constructor. |
WP_Widget_Media_Image::__construct()wp-includes/widgets/class-wp-widget-media-image.php | Constructor. |
wp_dashboard_events_news()wp-admin/includes/dashboard.php | Renders the Events and News dashboard widget. |
WP_Community_Events::format_event_data_time()wp-admin/includes/class-wp-community-events.php | Adds formatted date and time items for each event in an API response. |
get_theme_starter_content()wp-includes/theme.php | Expands a theme’s starter content configuration using core-provided data. |
_WP_Editors::get_translation()wp-includes/class-wp-editor.php | |
wp_print_update_row_templates()wp-admin/includes/update.php | Prints the JavaScript templates for update and deletion rows in list tables. |
rest_output_link_wp_head()wp-includes/rest-api.php | Outputs the REST API link tag into page header. |
rest_output_link_header()wp-includes/rest-api.php | Sends a Link header for the REST API. |
wp_oembed_add_discovery_links()wp-includes/embed.php | Adds oEmbed discovery links in the head element of the website. |
WP_Customize_Manager::customize_pane_settings()wp-includes/class-wp-customize-manager.php | Prints JavaScript settings for parent window. |
wp_get_document_title()wp-includes/general-template.php | Returns document title for the current page. |
wp_maybe_decline_date()wp-includes/functions.php | Determines if the date should be declined. |
WP_Screen::render_meta_boxes_preferences()wp-admin/includes/class-wp-screen.php | Renders the meta boxes preferences. |
WP_Users_List_Table::get_role_list()wp-admin/includes/class-wp-users-list-table.php | Returns an array of translated user role names for a given user object. |
WP_Customize_Nav_Menu_Setting::sanitize()wp-includes/customize/class-wp-customize-nav-menu-setting.php | Sanitize an input. |
WP_Customize_Nav_Menus::search_available_items_query()wp-includes/class-wp-customize-nav-menus.php | Performs post queries for available-item searching. |
WP_Customize_Nav_Menus::enqueue_scripts()wp-includes/class-wp-customize-nav-menus.php | Enqueues scripts and styles for Customizer pane. |
WP_Customize_Nav_Menus::customize_register()wp-includes/class-wp-customize-nav-menus.php | Adds the customizer settings and controls. |
WP_Customize_Nav_Menus::load_available_items_query()wp-includes/class-wp-customize-nav-menus.php | Performs the post_type and taxonomy queries for loading available menu items. |
WP_Posts_List_Table::handle_row_actions()wp-admin/includes/class-wp-posts-list-table.php | Generates and displays row action links. |
WP_MS_Themes_List_Table::column_name()wp-admin/includes/class-wp-ms-themes-list-table.php | Handles the name column output. |
WP_Comments_List_Table::handle_row_actions()wp-admin/includes/class-wp-comments-list-table.php | Generates and displays row actions links. |
WP_MS_Sites_List_Table::handle_row_actions()wp-admin/includes/class-wp-ms-sites-list-table.php | Generates and displays row action links. |
WP_MS_Users_List_Table::column_name()wp-admin/includes/class-wp-ms-users-list-table.php | Handles the name column output. |
WP_Customize_Theme_Control::content_template()wp-includes/customize/class-wp-customize-theme-control.php | Render a JS template for theme display. |
the_meta()wp-includes/post-template.php | Displays a list of post custom fields. |
customize_themes_print_templates()wp-admin/includes/theme.php | Prints JS templates for the theme-browsing UI in the Customizer. |
wp_install_maybe_enable_pretty_permalinks()wp-admin/includes/upgrade.php | Maybe enable pretty permalinks on installation. |
get_the_archive_title()wp-includes/general-template.php | Retrieves the archive title based on the queried object. |
get_the_posts_pagination()wp-includes/link-template.php | Retrieves a paginated navigation to next/previous set of posts, when applicable. |
wp_dropdown_languages()wp-includes/l10n.php | Displays or returns a Language selector. |
get_comments_number_text()wp-includes/comment-template.php | Displays the language string for the number of comments the current post has. |
login_footer()wp-login.php | Outputs the footer for the login page. |
network_step1()wp-admin/includes/network.php | Prints step 1 for Network installation process. |
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-ms-users-list-table.php | |
WP_MS_Users_List_Table::get_sortable_columns()wp-admin/includes/class-wp-ms-users-list-table.php | |
get_theme_update_available()wp-admin/includes/theme.php | Retrieves the update link if there is a theme update available. |
WP_Plugins_List_Table::get_bulk_actions()wp-admin/includes/class-wp-plugins-list-table.php | |
WP_Plugins_List_Table::single_row()wp-admin/includes/class-wp-plugins-list-table.php | |
WP_Links_List_Table::get_columns()wp-admin/includes/class-wp-links-list-table.php | |
WP_Links_List_Table::get_sortable_columns()wp-admin/includes/class-wp-links-list-table.php | |
install_themes_upload()wp-admin/includes/theme-install.php | Displays a form to upload themes from zip files. |
Theme_Upgrader_Skin::after()wp-admin/includes/class-theme-upgrader-skin.php | Performs an action following a single theme update. |
Plugin_Installer_Skin::after()wp-admin/includes/class-plugin-installer-skin.php | Performs an action following a plugin install. |
Theme_Installer_Skin::after()wp-admin/includes/class-theme-installer-skin.php | Performs an action following a single theme install. |
WP_List_Table::pagination()wp-admin/includes/class-wp-list-table.php | Displays the pagination. |
WP_Theme_Install_List_Table::install_theme_info()wp-admin/includes/class-wp-theme-install-list-table.php | Prints the info for a theme (to be used in the theme installer modal). |
populate_options()wp-admin/includes/schema.php | Create WordPress options and set the default values. |
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/class-wp-theme-install-list-table.php | Prints a theme from the WordPress.org API. |
wp_plugin_update_row()wp-admin/includes/update.php | Displays update information for a plugin. |
wp_theme_update_row()wp-admin/includes/update.php | Displays update information for a theme. |
install_plugins_upload()wp-admin/includes/plugin-install.php | Displays a form to upload plugins from zip files. |
install_plugin_information()wp-admin/includes/plugin-install.php | Displays plugin information in dialog box form. |
wp_dashboard_recent_posts()wp-admin/includes/dashboard.php | Generates Publishing Soon and Recently Published sections. |
wp_dashboard_plugins_output()wp-admin/includes/deprecated.php | Display plugins text for the WordPress news widget. |
wp_dashboard_recent_drafts()wp-admin/includes/dashboard.php | Show recent drafts of the user on the dashboard. |
_wp_dashboard_recent_comments_row()wp-admin/includes/dashboard.php | Outputs a row for the Recent Comments widget. |
wp_install_defaults()wp-admin/includes/upgrade.php | Creates the initial content for a newly-installed site. |
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/class-wp-plugin-install-list-table.php | |
list_meta()wp-admin/includes/template.php | Outputs a post’s public meta data in the Custom Fields meta box. |
WP_Themes_List_Table::display_rows()wp-admin/includes/class-wp-themes-list-table.php | |
WP_MS_Sites_List_Table::__construct()wp-admin/includes/class-wp-ms-sites-list-table.php | Constructor. |
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/class-wp-ms-sites-list-table.php | |
WP_MS_Sites_List_Table::get_sortable_columns()wp-admin/includes/class-wp-ms-sites-list-table.php | |
WP_Users_List_Table::single_row()wp-admin/includes/class-wp-users-list-table.php | Generates HTML for a single row on the users.php admin panel. |
WP_Users_List_Table::get_columns()wp-admin/includes/class-wp-users-list-table.php | Gets a list of columns for the list table. |
bulk_edit_posts()wp-admin/includes/post.php | Processes the post data for the bulk editing of posts. |
wp_prepare_revisions_for_js()wp-admin/includes/revision.php | Prepare revisions for JavaScript. |
wp_ajax_ajax_tag_search()wp-admin/includes/ajax-actions.php | Handles tag search via AJAX. |
wp_ajax_autocomplete_user()wp-admin/includes/ajax-actions.php | Handles user autocomplete via AJAX. |
post_submit_meta_box()wp-admin/includes/meta-boxes.php | Displays post submit form fields. |
attachment_submit_meta_box()wp-admin/includes/meta-boxes.php | Displays attachment submit form fields. |
post_tags_meta_box()wp-admin/includes/meta-boxes.php | Displays post tags form fields. |
WP_Media_List_Table::get_views()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_sortable_columns()wp-admin/includes/class-wp-media-list-table.php | |
WP_Media_List_Table::_get_row_actions()wp-admin/includes/class-wp-media-list-table.php | |
WP_Post_Comments_List_Table::get_column_info()wp-admin/includes/class-wp-post-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-comments-list-table.php | |
WP_Comments_List_Table::get_sortable_columns()wp-admin/includes/class-wp-comments-list-table.php | |
WP_Terms_List_Table::get_columns()wp-admin/includes/class-wp-terms-list-table.php | |
WP_Terms_List_Table::get_sortable_columns()wp-admin/includes/class-wp-terms-list-table.php | |
wp_nav_menu_item_post_type_meta_box()wp-admin/includes/nav-menu.php | Displays a meta box for a post type menu item. |
WP_Posts_List_Table::get_columns()wp-admin/includes/class-wp-posts-list-table.php | |
Custom_Image_Header::step_1()wp-admin/includes/class-custom-image-header.php | Displays first step of custom header image page. |
Custom_Image_Header::init()wp-admin/includes/class-custom-image-header.php | Sets up the hooks for the Custom Header admin page. |
Custom_Background::init()wp-admin/includes/class-custom-background.php | Sets up the hooks for the Custom Background admin page. |
WP_Customize_Manager::register_controls()wp-includes/class-wp-customize-manager.php | Registers some default controls. |
_ex()wp-includes/l10n.php | Displays translated string with gettext context. |
capital_P_dangit()wp-includes/formatting.php | Forever eliminate “Wordpress” from the planet (or at least the little bit we can influence). |
wp_trim_excerpt()wp-includes/formatting.php | Generates an excerpt from the content, if needed. |
wptexturize()wp-includes/formatting.php | Replaces common plain text characters with formatted entities. |
register_admin_color_schemes()wp-includes/general-template.php | Registers the default admin color schemes. |
feed_links()wp-includes/general-template.php | Displays the links to the general feeds. |
feed_links_extra()wp-includes/general-template.php | Displays the links to the extra feeds such as category feeds. |
get_calendar()wp-includes/general-template.php | Displays calendar with days that have posts as links. |
get_search_form()wp-includes/general-template.php | Displays search form. |
dropdown_cats()wp-includes/deprecated.php | Deprecated method for generating a drop-down of categories. |
WP_Theme::translate_header()wp-includes/class-wp-theme.php | Translates a theme header. |
WP_Query::get_search_stopwords()wp-includes/class-wp-query.php | Retrieves stopwords used when parsing search terms. |
size_format()wp-includes/functions.php | Converts a number of bytes to the largest unit the bytes will fit into. |
WP_Widget_Recent_Comments::widget()wp-includes/widgets/class-wp-widget-recent-comments.php | Outputs the content for the current Recent Comments widget instance. |
WP_Widget_Search::__construct()wp-includes/widgets/class-wp-widget-search.php | Sets up a new Search widget instance. |
WP_Locale::init()wp-includes/class-wp-locale.php | Sets up the translated strings and object properties. |
create_initial_taxonomies()wp-includes/taxonomy.php | Creates the initial taxonomies. |
get_taxonomy_labels()wp-includes/taxonomy.php | Builds an object with all taxonomy labels out of a taxonomy object. |
wp_admin_bar_new_content_menu()wp-includes/admin-bar.php | Adds “Add New” menu. |
wp_admin_bar_appearance_menu()wp-includes/admin-bar.php | Adds appearance submenu items to the “Site Name” menu. |
wp_insert_user()wp-includes/user.php | Inserts a user into the database. |
wp_dropdown_users()wp-includes/user.php | Creates dropdown HTML content of users. |
wp_post_revision_title()wp-includes/post-template.php | Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
wp_post_revision_title_expanded()wp-includes/post-template.php | Retrieves formatted date timestamp of a revision (linked to that revisions’s page). |
wp_set_post_terms()wp-includes/post.php | Sets the terms for a post. |
get_post_mime_types()wp-includes/post.php | Gets default post mime types. |
create_initial_post_types()wp-includes/post.php | Creates the initial post types when ‘init’ action is fired. |
wpmu_signup_blog_notification()wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new site. The new site will not become active until the confirmation link is clicked. |
wpmu_signup_user_notification()wp-includes/ms-functions.php | Sends a confirmation request email to a user when they sign up for a new user account (without signing up for a site at the same time). The user account will not become active until the confirmation link is clicked. |
get_post_format_strings()wp-includes/post-formats.php | Returns an array of post format slugs to their translated and pretty display versions |
wp_list_authors()wp-includes/author-template.php | Lists all the authors of the site, with several options available. |
comment_form()wp-includes/comment-template.php | Outputs a complete commenting form for use within a template. |
comment_type()wp-includes/comment-template.php | Displays the comment type of the current comment. |
get_comment_excerpt()wp-includes/comment-template.php | Retrieves the excerpt of the given comment. |
WP_Customize_Widgets::enqueue_scripts()wp-includes/class-wp-customize-widgets.php | Enqueues scripts and styles for Customizer panel and export data to JavaScript. |
wp_default_styles()wp-includes/script-loader.php | Assigns default styles to $styles object. |
wp_default_scripts()wp-includes/script-loader.php | Registers all WordPress scripts. |
get_comment_statuses()wp-includes/comment.php | Retrieves all of the WordPress supported comment statuses. |
_WP_Editors::editor()wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor. |
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
Example
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.”
Example
Inside the function, the _x() function is called with the provided parameters to perform the translation. The resulting translated string is stored in the $translated_text variable.
The following example demonstrates the usage of variables with the “_x() ” function: