Translates a singular string.
Parameters
$text
stringrequired- Text to translate.
$context
stringoptional- Context for the string.
Default:
''
$textdomain
stringoptional- Text domain. Default
'default'
.Default:
'default'
$locale
stringoptional- Locale. Default current locale.
Default:
null
Source
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];
}
Changelog
Version | Description |
---|---|
6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.