translate()
Retrieve the translation of $text.
If there is no translation, or the text domain isn't loaded, the original text is returned.
Note: Don't use translate() directly, use __() or related functions.
Hooks from the function
Return
String
. Translated text.
Usage
translate( $text, $domain );
- $text(string) (required)
- Text to translate.
- $domain(string)
- Text domain. Unique identifier for retrieving translated strings.
Default: 'default'
Examples
#1 Demo
$domain = 'my-textdomain'; $text = 'Some text to translate'; echo translate( $text, $domain );
Changelog
Since 2.2.0 | Introduced. |
Since 5.5.0 | Introduced gettext-{$domain} filter. |