WP_Translations::translate( string|null $singular, string|null $context =  ): string|null

In this article

Translates a singular string.

Parameters

$singularstring|nullrequired
Singular string.
$contextstring|nulloptional
Context.

Default:''

Return

string|null Translation if it exists, or the unchanged singular string

Source

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

Changelog

VersionDescription
6.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.