mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-02 19:54:28 +00:00
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:
@@ -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 ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user