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.

git-svn-id: https://develop.svn.wordpress.org/trunk@44239 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2018-12-16 22:23:34 +00:00
parent c687f1957e
commit a10598acd0
3 changed files with 33 additions and 9 deletions

View File

@@ -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 ] );
}
}
}