Make WordPress Core


Ignore:
Timestamp:
07/07/2020 06:38:20 PM (5 years ago)
Author:
ocean90
Message:

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

File:
1 edited

Legend:

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

    r48394 r48395  
    12251225        $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array( 'wp-lists', 'postbox' ), false, 1 );
    12261226
    1227         $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ) );
    1228         $scripts->add_data( 'comment', 'group', 1 );
    1229         did_action( 'init' ) && $scripts->localize(
    1230             'comment',
    1231             'commentL10n',
    1232             array(
    1233                 'submittedOn' => __( 'Submitted on:' ),
    1234                 /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
    1235                 'dateFormat'  => __( '%1$s %2$s, %3$s at %4$s:%5$s' ),
    1236             )
    1237         );
     1227        $scripts->add( 'comment', "/wp-admin/js/comment$suffix.js", array( 'jquery', 'postbox' ), false, 1 );
     1228        $scripts->set_translations( 'comment' );
    12381229
    12391230        $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ) );
Note: See TracChangeset for help on using the changeset viewer.