I18N: Set translations for all WordPress packages scripts.
Calls `wp_set_script_translations` for all packages scripts that have translations. Also correctly sets the domain on the translations. Props omarreiss, pento, ocean90. Merges [43878] to trunk. Fixes #45161. Built from https://develop.svn.wordpress.org/trunk@44239 git-svn-id: http://core.svn.wordpress.org/trunk@44069 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
030b1ba144
commit
9e54ec265c
|
@ -546,7 +546,8 @@ class WP_Scripts extends WP_Dependencies {
|
|||
}
|
||||
|
||||
$output = '(function( translations ){' .
|
||||
'wp.i18n.setLocaleData( translations.locale_data, "' . $domain . '" );' .
|
||||
'translations.locale_data.messages[""].domain = "' . $domain . '";' .
|
||||
'wp.i18n.setLocaleData( translations.locale_data.messages, "' . $domain . '" );' .
|
||||
'})(' . $json_translations . ');';
|
||||
|
||||
if ( $echo ) {
|
||||
|
|
|
@ -319,7 +319,7 @@ function wp_default_packages_scripts( &$scripts ) {
|
|||
'html-entities' => array( 'wp-polyfill' ),
|
||||
'i18n' => array( 'wp-polyfill' ),
|
||||
'is-shallow-equal' => array( 'wp-polyfill' ),
|
||||
'keycodes' => array( 'lodash', 'wp-polyfill' ),
|
||||
'keycodes' => array( 'lodash', 'wp-polyfill', 'wp-i18n' ),
|
||||
'list-reusable-blocks' => array(
|
||||
'lodash',
|
||||
'wp-api-fetch',
|
||||
|
@ -361,11 +361,28 @@ function wp_default_packages_scripts( &$scripts ) {
|
|||
'wordcount' => array( 'wp-polyfill' ),
|
||||
);
|
||||
|
||||
$package_translations = array(
|
||||
'api-fetch' => 'default',
|
||||
'blocks' => 'default',
|
||||
'block-library' => 'default',
|
||||
'components' => 'default',
|
||||
'edit-post' => 'default',
|
||||
'editor' => 'default',
|
||||
'format-library' => 'default',
|
||||
'keycodes' => 'default',
|
||||
'list-reusable-blocks' => 'default',
|
||||
'nux' => 'default',
|
||||
);
|
||||
|
||||
foreach ( $packages_dependencies as $package => $dependencies ) {
|
||||
$handle = 'wp-' . $package;
|
||||
$path = "/wp-includes/js/dist/$package$suffix.js";
|
||||
|
||||
$scripts->add( $handle, $path, $dependencies, false, 1 );
|
||||
|
||||
if ( isset( $package_translations[ $package ] ) ) {
|
||||
$scripts->set_translations( $handle, $package_translations[ $package ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.1-alpha-44238';
|
||||
$wp_version = '5.1-alpha-44239';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue