mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 11:35:48 +00: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. Merge of [44403] to the 5.0 branch. Props swissspidy. Fixes #45441. Built from https://develop.svn.wordpress.org/branches/5.0@44404 git-svn-id: http://core.svn.wordpress.org/branches/5.0@44234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a59e536374
commit
4bdc915736
@ -532,10 +532,13 @@ class WP_Scripts extends WP_Dependencies {
|
||||
$json_translations = '{ "locale_data": { "messages": { "": {} } } }';
|
||||
}
|
||||
|
||||
$output = '(function( translations ){' .
|
||||
'translations.locale_data.messages[""].domain = "' . $domain . '";' .
|
||||
'wp.i18n.setLocaleData( translations.locale_data.messages, "' . $domain . '" );' .
|
||||
'})(' . $json_translations . ');';
|
||||
$output = <<<JS
|
||||
( function( domain, translations ) {
|
||||
var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
|
||||
localeData[""].domain = domain;
|
||||
wp.i18n.setLocaleData( localeData, domain );
|
||||
} )( "{$domain}", {$json_translations} );
|
||||
JS;
|
||||
|
||||
if ( $echo ) {
|
||||
printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );
|
||||
@ -546,7 +549,7 @@ class WP_Scripts extends WP_Dependencies {
|
||||
|
||||
/**
|
||||
* Determines script dependencies.
|
||||
*
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @see WP_Dependencies::all_deps()
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.0.3-alpha-44401';
|
||||
$wp_version = '5.0.3-alpha-44404';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user