WordPress.org

Make WordPress Core

Changeset 48392


Ignore:
Timestamp:
07/07/2020 06:13:14 PM (7 months ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/plugin-install.js.

This removes the usage of wp_localize_script() for passing translations to the script and instead adds the translatable strings in the script directly through the use of wp.i18n and its utilities.

Props swissspidy, ocean90.
See #20491.
Fixes #50602.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/plugin-install.js

    r48168 r48392  
    55 */
    66
    7 /* global plugininstallL10n, tb_click, tb_remove, tb_position */
     7/* global tb_click, tb_remove, tb_position */
    88
    99jQuery( document ).ready( function( $ ) {
     
    157157    $( '.wrap' ).on( 'click', '.thickbox.open-plugin-details-modal', function( e ) {
    158158        // The `data-title` attribute is used only in the Plugin screens.
    159         var title = $( this ).data( 'title' ) ? plugininstallL10n.plugin_information + ' ' + $( this ).data( 'title' ) : plugininstallL10n.plugin_modal_label;
     159        var title = $( this ).data( 'title' ) ?
     160            wp.i18n.sprintf(
     161                // translators: %s: Plugin name.
     162                wp.i18n.__( 'Plugin: %s' ),
     163                $( this ).data( 'title' )
     164            ) :
     165            wp.i18n.__( 'Plugin details' );
    160166
    161167        e.preventDefault();
     
    171177            .attr({
    172178                'role': 'dialog',
    173                 'aria-label': plugininstallL10n.plugin_modal_label
     179                'aria-label': wp.i18n.__( 'Plugin details' )
    174180            })
    175181            .addClass( 'plugin-details-modal' );
  • trunk/src/wp-includes/script-loader.php

    r48391 r48392  
    12611261
    12621262        $scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'jquery-ui-core', 'thickbox' ), false, 1 );
    1263         did_action( 'init' ) && $scripts->localize(
    1264             'plugin-install',
    1265             'plugininstallL10n',
    1266             array(
    1267                 'plugin_information' => __( 'Plugin:' ),
    1268                 'plugin_modal_label' => __( 'Plugin details' ),
    1269                 'ays'                => __( 'Are you sure you want to install this plugin?' ),
    1270             )
    1271         );
     1263        $scripts->set_translations( 'plugin-install' );
    12721264
    12731265        $scripts->add( 'site-health', "/wp-admin/js/site-health$suffix.js", array( 'clipboard', 'jquery', 'wp-util', 'wp-a11y' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.