W3cubDocs

/WordPress

WP_Translations::make_entry( string $original, string $translations ): Translation_Entry

Builds a Translation_Entry from original string and translation strings.

Description

See also

Parameters

$originalstringrequired
Original string to translate from MO file. Might contain 0x04 as context separator or 0x00 as singular/plural separator.
$translationsstringrequired
Translation strings from MO file.

Return

Translation_Entry Entry instance.

Source

private function make_entry( $original, $translations ): Translation_Entry {
	$entry = new Translation_Entry();

	// Look for context, separated by \4.
	$parts = explode( "\4", $original );
	if ( isset( $parts[1] ) ) {
		$original       = $parts[1];
		$entry->context = $parts[0];
	}

	$entry->singular     = $original;
	$entry->translations = explode( "\0", $translations );
	$entry->is_plural    = count( $entry->translations ) > 1;

	return $entry;
}

Changelog

Version Description
6.5.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_translations/make_entry