MO::make_entry()

最后更新于:2021-11-25 20:31:55

MO::make_entry( string$original, string$translation)

Build a Translation_Entry from original string and translation strings, found in a MO file

参数

$original

(string) (Required) original string to translate from MO file. Might contain 0x04 as context separator or 0x00 as singular/plural separator

$translation

(string) (Required) translation string from MO file. Might contain 0x00 as a plural translations separator

响应

(Translation_Entry) Entry instance.

源文件

文件: gc-includes/pomo/mo.php

		function &make_entry( $original, $translation ) {
			$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];
			}
			// Look for plural original.
			$parts           = explode( "", $original );
			$entry->singular = $parts[0];
			if ( isset( $parts[1] ) ) {
				$entry->is_plural = true;
				$entry->plural    = $parts[1];
			}
			// Plural translations are also separated by .
			$entry->translations = explode( "", $translation );
			return $entry;
		}