wp_get_pomo_file_data() WordPress Function

The wp_get_pomo_file_data() function is used to retrieve data from a Gettext Portable Object (PO) file. PO files are used to store translations for a specific language. This function can be used to get the translation for a specific string, or to get all of the translations for a language. It returns an array of data, which can then be used in your WordPress site. To use this function, you need to specify the path to the PO file. You can either specify the full path, or use the WordPress directory constants. For example, to use the PO file in the WordPress root directory, you would use: wp_get_pomo_file_data( ABSPATH . 'my-translation.po' ); If you wanted to get the data for all of the available translations, you would use: wp_get_pomo_file_data( ABSPATH . 'languages/' ); This function is useful for retrieving translated strings from a PO file. It can be used to display a specific translation, or to get all available translations for a language.

wp_get_pomo_file_data( string $po_file ) #

Extract headers from a PO file.


Parameters

$po_file

(string)(Required)Path to PO file.


Top ↑

Return

(string[]) Array of PO file header values keyed by header name.


Top ↑

Source

File: wp-includes/l10n.php

function wp_get_pomo_file_data( $po_file ) {
	$headers = get_file_data(
		$po_file,
		array(
			'POT-Creation-Date'  => '"POT-Creation-Date',
			'PO-Revision-Date'   => '"PO-Revision-Date',
			'Project-Id-Version' => '"Project-Id-Version',
			'X-Generator'        => '"X-Generator',
		)
	);
	foreach ( $headers as $header => $value ) {
		// Remove possible contextual '\n' and closing double quote.
		$headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value );
	}
	return $headers;
}


Top ↑

Changelog

Changelog
VersionDescription
3.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.