Make WordPress Core


Ignore:
Timestamp:
07/06/2020 07:33:54 PM (6 years ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/theme-plugin-editor.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.

Fixes #50576.

File:
1 edited

Legend:

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

    r48340 r48346  
    10141014    $scripts->add( 'code-editor', "/wp-admin/js/code-editor$suffix.js", array( 'jquery', 'wp-codemirror', 'underscore' ) );
    10151015    $scripts->add( 'wp-theme-plugin-editor', "/wp-admin/js/theme-plugin-editor$suffix.js", array( 'wp-util', 'wp-sanitize', 'jquery', 'jquery-ui-core', 'wp-a11y', 'underscore' ) );
    1016     did_action( 'init' ) && $scripts->add_inline_script(
    1017         'wp-theme-plugin-editor',
    1018         sprintf(
    1019             'wp.themePluginEditor.l10n = %s;',
    1020             wp_json_encode(
    1021                 array(
    1022                     'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ),
    1023                     'saveError' => __( 'Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.' ),
    1024                     'lintError' => array(
    1025                         /* translators: %d: Error count. */
    1026                         'singular' => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 1 ),
    1027                         /* translators: %d: Error count. */
    1028                         'plural'   => _n( 'There is %d error which must be fixed before you can update this file.', 'There are %d errors which must be fixed before you can update this file.', 2 ),
    1029                         // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
    1030                     ),
    1031                 )
    1032             )
    1033         )
    1034     );
     1016    $scripts->set_translations( 'wp-theme-plugin-editor' );
    10351017
    10361018    $scripts->add( 'wp-playlist', "/wp-includes/js/mediaelement/wp-playlist$suffix.js", array( 'wp-util', 'backbone', 'mediaelement' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.