WP_Translations::translate()
Translates a singular string.
Method of the class: WP_Translations{}
No Hooks.
Return
String|null
. Translation if it exists, or the unchanged singular string
Usage
$WP_Translations = new WP_Translations(); $WP_Translations->translate( $singular, $context );
- $singular(string|null) (required)
- Singular string.
- $context(string|null)
- Context.
Default: ''
Changelog
Since 6.5.0 | Introduced. |
WP_Translations::translate() WP Translations::translate code WP 6.7.1
public function translate( $singular, $context = '' ) { if ( null === $singular ) { return null; } $translation = $this->controller->translate( $singular, (string) $context, $this->textdomain ); if ( false !== $translation ) { return $translation; } // Fall back to the original. return $singular; }