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
$textstringrequired- Text to translate.
$contextstringrequired- Context information for the translators.
$domainstringoptional- Text domain. Unique identifier for retrieving translated strings.
Default'default'.Default:
'default'
Source
*/ function _x( $text, $context, $domain = 'default' ) { return translate_with_gettext_context( $text, $context, $domain ); 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: