WordPress.org

Make WordPress Core

Changeset 48395


Ignore:
Timestamp:
07/07/2020 06:38:20 PM (3 months 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.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/comment.js

    r47122 r48395  
    33 */
    44
    5 /* global postboxes, commentL10n */
     5/* global postboxes */
    66
    77/**
     
    8585
    8686        $timestamp.html(
    87             commentL10n.submittedOn + ' <b>' +
    88             commentL10n.dateFormat
     87            wp.i18n.__( 'Submitted on:' ) + ' <b>' +
     88            /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */
     89            wp.i18n.__( '%1$s %2$s, %3$s at %4$s:%5$s' )
    8990                .replace( '%1$s', $( 'option[value="' + mm + '"]', '#mm' ).attr( 'data-text' ) )
    9091                .replace( '%2$s', parseInt( jj, 10 ) )
  • 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.