Make WordPress Core


Ignore:
Timestamp:
11/01/2018 01:50:59 PM (6 years ago)
Author:
herregroen
Message:

I18N: Improve JavaScript translation support.

Improves upon [43825] by adding unit tests to cover additional use-cases and changes loading translations to only occur when outputting the script to allow setting translations on dependencies.

Props atimmer, omarreiss, nerrad, swissspidy, ocean90.
Fixes #45103.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/functions.wp-scripts.php

    r43827 r43859  
    194194
    195195/**
    196  * Register translated strings for a script.
     196 * Sets translated strings for a script.
    197197 *
    198198 * Works only if the script has already been added.
    199199 *
    200200 * @see WP_Scripts::set_translations()
    201  * @link https://core.trac.wordpress.org/ticket/45103
    202201 * @global WP_Scripts $wp_scripts The WP_Scripts object for printing scripts.
    203202 *
     
    215214        _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
    216215        return false;
    217     }
    218 
    219     if ( ! wp_script_is( $handle, 'enqueued' ) ) {
    220         _doing_it_wrong( __FUNCTION__, __( 'Script translations may only be set if the script is enqueued.' ), '5.0.0' );
    221216    }
    222217
Note: See TracChangeset for help on using the changeset viewer.