Translations::translate()publicWP 2.8.0

Translates a singular string.

Method of the class: Translations{}

No Hooks.

Return

String.

Usage

$Translations = new Translations();
$Translations->translate( $singular, $context );
$singular(string) (required)
-
$context(string)
-
Default: null

Changelog

Since 2.8.0 Introduced.

Translations::translate() code WP 6.7.2

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;
}