i18n: Add the wp_get_jed_locale_data() function.

This function formats locale information to be used by Jed.

Props desrosj.
See #45111.


Built from https://develop.svn.wordpress.org/branches/5.0@43759


git-svn-id: http://core.svn.wordpress.org/branches/5.0@43588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-10-19 05:52:25 +00:00
parent dbb5cd9960
commit 98eb507bbe
2 changed files with 30 additions and 1 deletions

View File

@ -1332,3 +1332,32 @@ function is_locale_switched() {
return $wp_locale_switcher->is_switched();
}
/**
* Returns Jed-formatted localization data.
*
* @since 5.0.0
*
* @param string $domain Translation domain.
* @return array Jed-formatted localization data.
*/
function wp_get_jed_locale_data( $domain ) {
$translations = get_translations_for_domain( $domain );
$locale = array(
'' => array(
'domain' => $domain,
'lang' => is_admin() ? get_user_locale() : get_locale(),
),
);
if ( ! empty( $translations->headers['Plural-Forms'] ) ) {
$locale['']['plural_forms'] = $translations->headers['Plural-Forms'];
}
foreach ( $translations->entries as $msgid => $entry ) {
$locale[ $msgid ] = $entry->translations;
}
return $locale;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.0-alpha-43758';
$wp_version = '5.0-alpha-43759';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.