Displays translated text.
Parameters
$text
stringrequired- Text to translate.
$domain
stringoptional- Text domain. Unique identifier for retrieving translated strings.
Default'default'
.Default:
'default'
Source
function _e( $text, $domain = 'default' ) {
echo translate( $text, $domain );
}
Changelog
Version | Description |
---|---|
1.2.0 | Introduced. |
Basic Example
Display some translated text:
The WordPress documentation states that you should not use
but use
instead.
In this function,the “$domain” is used to locate the multilingual file.(The file which is the translation of your theme.)
In wp-include there is a function related to this var
You can see $domain is used in this file.Actually it’s used to locate the .mo file.So you must may sure it share the same name with your theme folder name
This function is same as
echo __
like:Important security note:
_e()
is not an escaping function. Since all output really needs to be escaped, consider using__()
instead.For example, this is safe:
echo esc_html( __( 'This is my translatable text' ) )
But this might not be, because the output can get filtered and is not escaped close to where it is output:
_e( 'This is my translatable text' )
esc_html_e
instead of_e
Use escaping functions instead,
which is the equivalent of,