translate
Retrieve the translation of $text.
Description
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.
Returns (string)
Translated text
Parameters (2)
- 0. $text (string)
- Text to translate.
- 1. $domain — Optional. (string) =>
'default'
- Text domain. Unique identifier for retrieving translated strings. Default default..
Usage
if ( !function_exists( 'translate' ) ) { require_once ABSPATH . WPINC . '/l10n.php'; } // Text to translate. $text = ''; // Optional. Text domain. Unique identifier for retrieving translated strings. // Default 'default'. $domain = 'default'; // NOTICE! Understand what this does before running. $result = translate($text, $domain);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/l10n.php
- function translate( $text, $domain = 'default' ) {
- $translations = get_translations_for_domain( $domain );
- $translation = $translations->translate( $text );
- /**
- * Filters text with its translation.
- *
- * @since 2.0.11
- *
- * @param string $translation Translated text.
- * @param string $text Text to translate.
- * @param string $domain Text domain. Unique identifier for retrieving translated strings.
- */
- return apply_filters( 'gettext', $translation, $text, $domain );
- }