WP_Translation_Controller::translate
Translates a singular string.
Метод класса: WP_Translation_Controller{}
Хуков нет.
Возвращает
Строку|false. Translation on success, false otherwise.
Использование
$WP_Translation_Controller = new WP_Translation_Controller(); $WP_Translation_Controller->translate( $text, $context, $textdomain, ?string $locale );
- $text(строка) (обязательный)
- Text to translate.
- $context(строка)
- Context for the string.
По умолчанию:empty string - $textdomain(строка)
- Text domain.
По умолчанию:'default' - ?string $locale
- .
По умолчанию:null
Список изменений
| С версии 6.5.0 | Введена. |
Код WP_Translation_Controller::translate() WP Translation Controller::translate WP 7.0
public function translate( string $text, string $context = '', string $textdomain = 'default', ?string $locale = null ) {
if ( '' !== $context ) {
$context .= "\4";
}
$translation = $this->locate_translation( "{$context}{$text}", $textdomain, $locale );
if ( false === $translation ) {
return false;
}
return $translation['entries'][0];
}