Make WordPress Core


Ignore:
Timestamp:
11/08/2018 11:33:46 AM (6 years ago)
Author:
herregroen
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.
Fixes #45161.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/script-loader.php

    r43877 r43878  
    321321        'i18n' => array( 'wp-polyfill' ),
    322322        'is-shallow-equal' => array( 'wp-polyfill' ),
    323         'keycodes' => array( 'lodash', 'wp-polyfill' ),
     323        'keycodes' => array( 'lodash', 'wp-polyfill', 'wp-i18n' ),
    324324        'list-reusable-blocks' => array(
    325325            'lodash',
     
    364364    );
    365365
     366    $package_translations = array(
     367        'api-fetch' => 'default',
     368        'blocks' => 'default',
     369        'block-library' => 'default',
     370        'components' => 'default',
     371        'edit-post' => 'default',
     372        'editor' => 'default',
     373        'format-library' => 'default',
     374        'keycodes' => 'default',
     375        'list-reusable-blocks' => 'default',
     376        'nux' => 'default',
     377    );
     378
    366379    foreach ( $packages_dependencies as $package => $dependencies ) {
    367380        $handle  = 'wp-' . $package;
     
    369382
    370383        $scripts->add( $handle, $path, $dependencies, false, 1 );
     384
     385        if ( isset( $package_translations[ $package ] ) ) {
     386            $scripts->set_translations( $handle, $package_translations[ $package ] );
     387        }
    371388    }
    372389}
Note: See TracChangeset for help on using the changeset viewer.