WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/ x

Contents

Description

Retrieve translated string with gettext context

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.

Usage

<?php _x$text$context$domain ?>

Parameters

$text
(string) (required) Text to translate
Default: None
$context
(string) (required) Context information for the translators
Default: None
$domain
(string) (optional) Domain to retrieve the translated text
Default: 'default'

Return Values

(string) 
Translated context string.

Examples

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

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."

Notes

  • l10n is an abbreviation for localization.

Change Log

Source File

_x() is located in wp-includes/l10n.php.

Related

L10n: translate(), __(), _e(), _n(), _x(), _ex(), _nx(), esc_attr__(), esc_attr_e(), esc_attr_x(), esc_html__(), esc_html_e(), esc_html_x(), _n_noop(), _nx_noop(), translate_nooped_plural()

See also index of Function Reference and index of Template Tags.