mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-24 21:32:51 +02:00
I18N/Script Loader: Support text domains other than "messages".
The inline JavaScript added by `WP_Scripts::print_translations()` should check whether `locale_data.$text_domain` exists and fall back to `locale_data.messages` otherwise. Props swissspidy. See #45441. Built from https://develop.svn.wordpress.org/trunk@44403 git-svn-id: http://core.svn.wordpress.org/trunk@44233 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1c4a23faad
commit
49351e0578
@ -546,10 +546,13 @@ class WP_Scripts extends WP_Dependencies {
|
|||||||
$json_translations = '{ "locale_data": { "messages": { "": {} } } }';
|
$json_translations = '{ "locale_data": { "messages": { "": {} } } }';
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = '(function( translations ){' .
|
$output = <<<JS
|
||||||
'translations.locale_data.messages[""].domain = "' . $domain . '";' .
|
( function( domain, translations ) {
|
||||||
'wp.i18n.setLocaleData( translations.locale_data.messages, "' . $domain . '" );' .
|
var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
|
||||||
'})(' . $json_translations . ');';
|
localeData[""].domain = domain;
|
||||||
|
wp.i18n.setLocaleData( localeData, domain );
|
||||||
|
} )( "{$domain}", {$json_translations} );
|
||||||
|
JS;
|
||||||
|
|
||||||
if ( $echo ) {
|
if ( $echo ) {
|
||||||
printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
|
printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.1-alpha-44402';
|
$wp_version = '5.1-alpha-44403';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user