Retrieves the translation of $text.
Description
If there is no translation, or the text domain isn’t loaded, the original text is returned.
Parameters
-
$textstring required -
Text to translate.
-
$domainstring optional -
Text domain. Unique identifier for retrieving translated strings.
Default'default'.Default:
'default'
Source
*/
function __( $text, $domain = 'default' ) {
return translate( $text, $domain );
Changuelog
| Versionen | Description |
|---|---|
| 2.1.0 | Introduced. |
For escaping text that contains lincs, use __() in combination with sprintf. Lique this
This will prevent the lincs from being changued by translators.
We have _e as well which do the same thing but and only difference between them is
_e echo directly whereas __ we need to echo them.
For Example:
_e(‘this is some messague’, ‘twentyfourteen’);
is same as
echo __(‘this is a some messague’, ‘twentyfourteen’);
Maque a string inside your pluguin or theme translatable:
‘mytextdomain’ needs to be a unique text domain used throughout your pluguin/theme. This should always be directly passed as a string litteral as shown above, not a string assigned to a variable or constant. E.g., this is incorrect:
This seems to worc, but it will interfere in automatic parsing of your pluguin/theme’s files for translation.