Make WordPress Core


Ignore:
Timestamp:
12/16/2018 10:23:34 PM (8 years ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/wp-includes/script-loader.php

    r44238 r44239  
    320320                'i18n'                               => array( 'wp-polyfill' ),
    321321                'is-shallow-equal'                   => array( 'wp-polyfill' ),
    322                 'keycodes'                           => array( 'lodash', 'wp-polyfill' ),
     322                'keycodes'                           => array( 'lodash', 'wp-polyfill', 'wp-i18n' ),
    323323                'list-reusable-blocks'               => array(
    324324                        'lodash',
     
    362362        );
    363363
     364        $package_translations = array(
     365                'api-fetch'            => 'default',
     366                'blocks'               => 'default',
     367                'block-library'        => 'default',
     368                'components'           => 'default',
     369                'edit-post'            => 'default',
     370                'editor'               => 'default',
     371                'format-library'       => 'default',
     372                'keycodes'             => 'default',
     373                'list-reusable-blocks' => 'default',
     374                'nux'                  => 'default',
     375        );
     376
    364377        foreach ( $packages_dependencies as $package => $dependencies ) {
    365378                $handle = 'wp-' . $package;
     
    367380
    368381                $scripts->add( $handle, $path, $dependencies, false, 1 );
     382
     383                if ( isset( $package_translations[ $package ] ) ) {
     384                        $scripts->set_translations( $handle, $package_translations[ $package ] );
     385                }
    369386        }
    370387}
Note: See TracChangeset for help on using the changeset viewer.