WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/07/2020 04:47:14 PM (17 months ago)
Author:
ocean90
Message:

I18N: Use wp.i18n for translatable strings in wp-admin/js/post.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 #50599.

File:
1 edited

Legend:

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

    r48384 r48385  
    12201220        $scripts->add( 'post', "/wp-admin/js/post$suffix.js", array( 'suggest', 'wp-lists', 'postbox', 'tags-box', 'underscore', 'word-count', 'wp-a11y', 'wp-sanitize', 'clipboard' ), false, 1 );
    12211221        $scripts->set_translations( 'post' );
    1222         did_action( 'init' ) && $scripts->localize(
    1223             'post',
    1224             'postL10n',
    1225             array(
    1226                 'ok'                 => __( 'OK' ),
    1227                 'cancel'             => __( 'Cancel' ),
    1228                 'publishOn'          => __( 'Publish on:' ),
    1229                 'publishOnFuture'    => __( 'Schedule for:' ),
    1230                 'publishOnPast'      => __( 'Published on:' ),
    1231                 /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
    1232                 'dateFormat'         => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
    1233                 'showcomm'           => __( 'Show more comments' ),
    1234                 'endcomm'            => __( 'No more comments found.' ),
    1235                 'publish'            => __( 'Publish' ),
    1236                 'schedule'           => _x( 'Schedule', 'post action/button label' ),
    1237                 'update'             => __( 'Update' ),
    1238                 'savePending'        => __( 'Save as Pending' ),
    1239                 'saveDraft'          => __( 'Save Draft' ),
    1240                 'private'            => __( 'Private' ),
    1241                 'public'             => __( 'Public' ),
    1242                 'publicSticky'       => __( 'Public, Sticky' ),
    1243                 'password'           => __( 'Password Protected' ),
    1244                 'privatelyPublished' => __( 'Privately Published' ),
    1245                 'published'          => __( 'Published' ),
    1246                 'saveAlert'          => __( 'The changes you made will be lost if you navigate away from this page.' ),
    1247                 'savingText'         => __( 'Saving Draft…' ),
    1248                 'permalinkSaved'     => __( 'Permalink saved' ),
    1249             )
    1250         );
    12511222
    12521223        $scripts->add( 'editor-expand', "/wp-admin/js/editor-expand$suffix.js", array( 'jquery', 'underscore' ), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.