Translates a singular string.
Parameters
$textstringrequired- Text to translate.
$contextstringoptional- Context for the string.
Default:
'' $textdomainstringoptional- Text domain. Default
'default'.Default:
'default' $localestringoptional- 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.