Translations::translate
Translates a singular string.
Method of the class: Translations{}
No Hooks.
Returns
String.
Usage
$Translations = new Translations(); $Translations->translate( $singular, $context );
- $singular(string) (required)
- .
- $context(string)
- .
Default: null
Changelog
| Since 2.8.0 | Introduced. |
Translations::translate() Translations::translate code WP 6.9
public function translate( $singular, $context = null ) {
$entry = new Translation_Entry(
array(
'singular' => $singular,
'context' => $context,
)
);
$translated = $this->translate_entry( $entry );
return ( $translated && ! empty( $translated->translations ) ) ? $translated->translations[0] : $singular;
}