Make WordPress Core

Ticket #45489: 45489.2.diff

File 45489.2.diff, 4.7 KB (added by swissspidy, 6 years ago)
  • src/wp-includes/class.wp-scripts.php

    diff --git src/wp-includes/class.wp-scripts.php src/wp-includes/class.wp-scripts.php
    index e843233cbc..00a1d00aad 100644
    class WP_Scripts extends WP_Dependencies { 
    499499         * Sets a translation textdomain.
    500500         *
    501501         * @since 5.0.0
     502         * @since 5.0.3 The `$domain` parameter was made optional.
    502503         *
    503504         * @param string $handle Name of the script to register a translation domain to.
    504          * @param string $domain The textdomain.
     505         * @param string $domain Optional. Text domain. Default 'default'.
    505506         * @param string $path   Optional. The full file path to the directory containing translation files.
    506507         *
    507508         * @return bool True if the textdomain was registered, false if not.
    508509         */
    509         public function set_translations( $handle, $domain, $path = null ) {
     510        public function set_translations( $handle, $domain = 'default', $path = null ) {
    510511                if ( ! isset( $this->registered[ $handle ] ) ) {
    511512                        return false;
    512513                }
    class WP_Scripts extends WP_Dependencies { 
    517518                if ( ! in_array( 'wp-i18n', $obj->deps, true ) ) {
    518519                        $obj->deps[] = 'wp-i18n';
    519520                }
     521
    520522                return $obj->set_translations( $domain, $path );
    521523        }
    522524
  • src/wp-includes/functions.wp-scripts.php

    diff --git src/wp-includes/functions.wp-scripts.php src/wp-includes/functions.wp-scripts.php
    index 5aa26cca5e..2302433942 100644
    function wp_localize_script( $handle, $object_name, $l10n ) { 
    209209 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
    210210 *
    211211 * @since 5.0.0
     212 * @since 5.0.3 The `$domain` parameter was made optional.
    212213 *
    213214 * @param string $handle Script handle the textdomain will be attached to.
    214  * @param string $domain The textdomain.
     215 * @param string $domain Optional. Text domain. Default 'default'.
    215216 * @param string $path   Optional. The full file path to the directory containing translation files.
    216217 *
    217218 * @return bool True if the textdomain was successfully localized, false otherwise.
    218219 */
    219 function wp_set_script_translations( $handle, $domain, $path = null ) {
     220function wp_set_script_translations( $handle, $domain = 'default', $path = null ) {
    220221        global $wp_scripts;
    221222        if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
    222223                _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
  • src/wp-includes/l10n.php

    diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php
    index 7dd86607ec..8bdd5754c4 100644
    function load_child_theme_textdomain( $domain, $path = false ) { 
    898898 *
    899899 * @since 5.0.0
    900900 * @since 5.0.2 Uses load_script_translations() to load translation data.
     901 * @since 5.0.3 The `$domain` parameter was made optional.
    901902 *
    902903 * @see WP_Scripts::set_translations()
    903904 *
    904905 * @param string $handle Name of the script to register a translation domain to.
    905  * @param string $domain The text domain.
     906 * @param string $domain Optional. Text domain. Default 'default'.
    906907 * @param string $path   Optional. The full file path to the directory containing translation files.
    907908 *
    908909 * @return false|string False if the script textdomain could not be loaded, the translated strings
    909910 *                      in JSON encoding otherwise.
    910911 */
    911 function load_script_textdomain( $handle, $domain, $path = null ) {
     912function load_script_textdomain( $handle, $domain = 'default', $path = null ) {
    912913        $wp_scripts = wp_scripts();
    913914
    914915        if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 2772ab6eb8..17c8042911 100644
    function wp_default_packages_scripts( &$scripts ) { 
    466466        );
    467467
    468468        $package_translations = array(
    469                 'api-fetch'            => 'default',
    470                 'blocks'               => 'default',
    471                 'block-library'        => 'default',
    472                 'components'           => 'default',
    473                 'edit-post'            => 'default',
    474                 'editor'               => 'default',
    475                 'format-library'       => 'default',
    476                 'keycodes'             => 'default',
    477                 'list-reusable-blocks' => 'default',
    478                 'nux'                  => 'default',
     469                'api-fetch',
     470                'blocks',
     471                'block-library',
     472                'components',
     473                'edit-post',
     474                'editor',
     475                'format-library',
     476                'keycodes',
     477                'list-reusable-blocks',
     478                'nux',
    479479        );
    480480
    481481        foreach ( $packages_dependencies as $package => $dependencies ) {
    function wp_default_packages_scripts( &$scripts ) { 
    485485
    486486                $scripts->add( $handle, $path, $dependencies, $version, 1 );
    487487
    488                 if ( isset( $package_translations[ $package ] ) ) {
    489                         $scripts->set_translations( $handle, $package_translations[ $package ] );
     488                if ( in_array( $package, $package_translations, true ) ) {
     489                        $scripts->set_translations( $handle );
    490490                }
    491491        }
    492492}