WordPress.org

Make WordPress Core

Changeset 31941


Ignore:
Timestamp:
03/31/2015 06:44:46 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Decouple strings where the singular and plural form are not just the same string with different numbers, but essentially two different strings.

This allows for using proper plural forms in languages with more than two forms, and also resolves string conflicts when the same string is present in both singular and plural form.

fixes #28502.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit.php

    r31709 r31941  
    248248$bulk_messages['post'] = array(
    249249    'updated'   => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ),
    250     'locked'    => _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ),
     250    'locked'    => ( 1 == $bulk_counts['locked'] ) ? __( '1 post not updated, somebody is editing it.' ) :
     251                       _n( '%s post not updated, somebody is editing it.', '%s posts not updated, somebody is editing them.', $bulk_counts['locked'] ),
    251252    'deleted'   => _n( '%s post permanently deleted.', '%s posts permanently deleted.', $bulk_counts['deleted'] ),
    252253    'trashed'   => _n( '%s post moved to the Trash.', '%s posts moved to the Trash.', $bulk_counts['trashed'] ),
     
    255256$bulk_messages['page'] = array(
    256257    'updated'   => _n( '%s page updated.', '%s pages updated.', $bulk_counts['updated'] ),
    257     'locked'    => _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ),
     258    'locked'    => ( 1 == $bulk_counts['locked'] ) ? __( '1 page not updated, somebody is editing it.' ) :
     259                       _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $bulk_counts['locked'] ),
    258260    'deleted'   => _n( '%s page permanently deleted.', '%s pages permanently deleted.', $bulk_counts['deleted'] ),
    259261    'trashed'   => _n( '%s page moved to the Trash.', '%s pages moved to the Trash.', $bulk_counts['trashed'] ),
  • trunk/src/wp-admin/includes/ajax-actions.php

    r31897 r31941  
    380380        'id' => $comment_id,
    381381        'supplemental' => array(
    382             'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ),
     382            'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
    383383            'total_pages' => ceil( $total / $per_page ),
    384384            'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ),
  • trunk/src/wp-admin/network.php

    r31200 r31941  
    414414        $num_keys_salts = count( $keys_salts );
    415415?>
    416     <p><?php
    417         echo _n( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts ); ?> <?php _e( 'To make your installation more secure, you should also add:' ) ?></p>
     416    <p>
     417        <?php
     418            if ( 1 == $num_keys_salts ) {
     419                _e( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.' );
     420            } else {
     421                _e( 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.' );
     422            }
     423        ?>
     424        <?php _e( 'To make your installation more secure, you should also add:' ); ?>
     425    </p>
    418426    <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php echo esc_textarea( $keys_salts_str ); ?></textarea>
    419427<?php
  • trunk/src/wp-admin/network/themes.php

    r31696 r31941  
    147147                wp_enqueue_script( 'jquery' );
    148148                require_once( ABSPATH . 'wp-admin/admin-header.php' );
     149                $themes_to_delete = count( $themes );
    149150                ?>
    150151            <div class="wrap">
    151                 <?php
    152                     $themes_to_delete = count( $themes );
    153                     echo '<h2>' . _n( 'Delete Theme', 'Delete Themes', $themes_to_delete ) . '</h2>';
    154                 ?>
    155                 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This theme may be active on other sites in the network.', 'These themes may be active on other sites in the network.', $themes_to_delete ); ?></p></div>
    156                 <p><?php echo _n( 'You are about to remove the following theme:', 'You are about to remove the following themes:', $themes_to_delete ); ?></p>
     152                <?php if ( 1 == $themes_to_delete ) : ?>
     153                    <h2><?php _e( 'Delete Theme' ); ?></h2>
     154                    <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This theme may be active on other sites in the network.' ); ?></p></div>
     155                    <p><?php _e( 'You are about to remove the following theme:' ); ?></p>
     156                <?php else : ?>
     157                    <h2><?php _e( 'Delete Themes' ); ?></h2>
     158                    <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These themes may be active on other sites in the network.' ); ?></p></div>
     159                    <p><?php _e( 'You are about to remove the following themes:' ); ?></p>
     160                <?php endif; ?>
    157161                    <ul class="ul-disc">
    158162                    <?php
     
    163167                    ?>
    164168                    </ul>
    165                 <p><?php _e('Are you sure you wish to delete these themes?'); ?></p>
     169                <?php if ( 1 == $themes_to_delete ) : ?>
     170                    <p><?php _e( 'Are you sure you wish to delete this theme?' ); ?></p>
     171                <?php else : ?>
     172                    <p><?php _e( 'Are you sure you wish to delete these themes?' ); ?></p>
     173                <?php endif; ?>
    166174                <form method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>" style="display:inline;">
    167175                    <input type="hidden" name="verify-delete" value="1" />
     
    171179                            echo '<input type="hidden" name="checked[]" value="' . esc_attr($theme) . '" />';
    172180                        }
     181
     182                        wp_nonce_field( 'bulk-themes' );
     183
     184                        if ( 1 == $themes_to_delete ) {
     185                            submit_button( __( 'Yes, Delete this theme' ), 'button', 'submit', false );
     186                        } else {
     187                            submit_button( __( 'Yes, Delete these themes' ), 'button', 'submit', false );
     188                        }
    173189                    ?>
    174                     <?php wp_nonce_field('bulk-themes') ?>
    175                     <?php submit_button( _n( 'Yes, Delete this theme', 'Yes, Delete these themes', $themes_to_delete ), 'button', 'submit', false ); ?>
    176190                </form>
    177191                <?php
     
    255269<?php
    256270if ( isset( $_GET['enabled'] ) ) {
    257     $_GET['enabled'] = absint( $_GET['enabled'] );
    258     echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme enabled.', '%s themes enabled.', $_GET['enabled'] ), number_format_i18n( $_GET['enabled'] ) ) . '</p></div>';
     271    $enabled = absint( $_GET['enabled'] );
     272    if ( 1 == $enabled ) {
     273        $message = __( 'Theme enabled.' );
     274    } else {
     275        $message = _n( '%s theme enabled.', '%s themes enabled.', $enabled );
     276    }
     277    echo '<div id="message" class="updated"><p>' . sprintf( $message, number_format_i18n( $enabled ) ) . '</p></div>';
    259278} elseif ( isset( $_GET['disabled'] ) ) {
    260     $_GET['disabled'] = absint( $_GET['disabled'] );
    261     echo '<div id="message" class="updated"><p>' . sprintf( _n( 'Theme disabled.', '%s themes disabled.', $_GET['disabled'] ), number_format_i18n( $_GET['disabled'] ) ) . '</p></div>';
     279    $disabled = absint( $_GET['disabled'] );
     280    if ( 1 == $disabled ) {
     281        $message = __( 'Theme disabled.' );
     282    } else {
     283        $message = _n( '%s theme disabled.', '%s themes disabled.', $disabled );
     284    }
     285    echo '<div id="message" class="updated"><p>' . sprintf( $message, number_format_i18n( $disabled ) ) . '</p></div>';
    262286} elseif ( isset( $_GET['deleted'] ) ) {
    263     $_GET['deleted'] = absint( $_GET['deleted'] );
    264     echo '<div id="message" class="updated"><p>' . sprintf( _nx( 'Theme deleted.', '%s themes deleted.', $_GET['deleted'], 'network' ), number_format_i18n( $_GET['deleted'] ) ) . '</p></div>';
     287    $deleted = absint( $_GET['deleted'] );
     288    if ( 1 == $deleted ) {
     289        $message = __( 'Theme deleted.' );
     290    } else {
     291        $message = _n( '%s theme deleted.', '%s themes deleted.', $deleted );
     292    }
     293    echo '<div id="message" class="updated"><p>' . sprintf( $message, number_format_i18n( $deleted ) ) . '</p></div>';
    265294} elseif ( isset( $_GET['error'] ) && 'none' == $_GET['error'] ) {
    266295    echo '<div id="message" class="error"><p>' . __( 'No theme selected.' ) . '</p></div>';
  • trunk/src/wp-admin/network/users.php

    r31696 r31941  
    2525    <h2><?php esc_html_e( 'Users' ); ?></h2>
    2626
    27     <?php if ( count( $users ) > 1 ) : ?>
     27    <?php if ( 1 == count( $users ) ) : ?>
     28        <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
     29    <?php else : ?>
    2830        <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p>
    29     <?php else : ?>
    30         <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p>
    3131    <?php endif; ?>
    3232
     
    104104    do_action( 'delete_user_form', $current_user );
    105105
    106     if ( count( $users ) > 1 ) : ?>
     106    if ( 1 == count( $users ) ) : ?>
     107        <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
     108    <?php else : ?>
    107109        <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, these users will be permanently removed.' ); ?></p>
    108     <?php else : ?>
    109         <p><?php _e( 'Once you hit &#8220;Confirm Deletion&#8221;, the user will be permanently removed.' ); ?></p>
    110110    <?php endif;
    111111
  • trunk/src/wp-admin/plugins.php

    r31811 r31941  
    284284                    }
    285285                    $plugins_to_delete = count( $plugin_info );
    286                     echo '<h2>' . _n( 'Delete Plugin', 'Delete Plugins', $plugins_to_delete ) . '</h2>';
    287286                ?>
    288                 <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
    289                 <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo _n( 'This plugin may be active on other sites in the network.', 'These plugins may be active on other sites in the network.', $plugins_to_delete ); ?></p></div>
     287                <?php if ( 1 == $plugins_to_delete ) : ?>
     288                    <h2><?php _e( 'Delete Plugin' ); ?></h2>
     289                    <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
     290                        <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
     291                    <?php endif; ?>
     292                    <p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
     293                <?php else: ?>
     294                    <h2><?php _e( 'Delete Plugins' ); ?></h2>
     295                    <?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
     296                        <div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
     297                    <?php endif; ?>
     298                    <p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
    290299                <?php endif; ?>
    291                 <p><?php echo _n( 'You are about to remove the following plugin:', 'You are about to remove the following plugins:', $plugins_to_delete ); ?></p>
    292300                    <ul class="ul-disc">
    293301                        <?php
  • trunk/src/wp-admin/upload.php

    r31696 r31941  
    220220$message = '';
    221221if ( ! empty( $_GET['posted'] ) ) {
    222     $message = __('Media attachment updated.');
     222    $message = __( 'Media attachment updated.' );
    223223    $_SERVER['REQUEST_URI'] = remove_query_arg(array('posted'), $_SERVER['REQUEST_URI']);
    224224}
    225225
    226226if ( ! empty( $_GET['attached'] ) && $attached = absint( $_GET['attached'] ) ) {
    227     $message = sprintf( _n('Reattached %d attachment.', 'Reattached %d attachments.', $attached), $attached );
     227    $message = sprintf( _n( 'Reattached %d attachment.', 'Reattached %d attachments.', $attached ), $attached );
    228228    $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'detach', 'attached' ), $_SERVER['REQUEST_URI'] );
    229229}
     
    235235
    236236if ( ! empty( $_GET['deleted'] ) && $deleted = absint( $_GET['deleted'] ) ) {
    237     $message = sprintf( _n( 'Media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted ), number_format_i18n( $_GET['deleted'] ) );
     237    if ( 1 == $deleted ) {
     238        $message = __( 'Media attachment permanently deleted.' );
     239    } else {
     240        $message = _n( '%d media attachment permanently deleted.', '%d media attachments permanently deleted.', $deleted );
     241    }
     242    $message = sprintf( $message, number_format_i18n( $deleted ) );
    238243    $_SERVER['REQUEST_URI'] = remove_query_arg(array('deleted'), $_SERVER['REQUEST_URI']);
    239244}
    240245
    241246if ( ! empty( $_GET['trashed'] ) && $trashed = absint( $_GET['trashed'] ) ) {
    242     $message = sprintf( _n( 'Media attachment moved to the trash.', '%d media attachments moved to the trash.', $trashed ), number_format_i18n( $_GET['trashed'] ) );
     247    if ( 1 == $trashed ) {
     248        $message = __( 'Media attachment moved to the trash.' );
     249    } else {
     250        $message = _n( '%d media attachment moved to the trash.', '%d media attachments moved to the trash.', $trashed );
     251    }
     252    $message = sprintf( $message, number_format_i18n( $trashed ) );
    243253    $message .= ' <a href="' . esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids='.(isset($_GET['ids']) ? $_GET['ids'] : ''), "bulk-media" ) ) . '">' . __('Undo') . '</a>';
    244254    $_SERVER['REQUEST_URI'] = remove_query_arg(array('trashed'), $_SERVER['REQUEST_URI']);
     
    246256
    247257if ( ! empty( $_GET['untrashed'] ) && $untrashed = absint( $_GET['untrashed'] ) ) {
    248     $message = sprintf( _n( 'Media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed ), number_format_i18n( $_GET['untrashed'] ) );
     258    if ( 1 == $untrashed ) {
     259        $message = __( 'Media attachment restored from the trash.' );
     260    } else {
     261        $message = _n( '%d media attachment restored from the trash.', '%d media attachments restored from the trash.', $untrashed );
     262    }
     263    $message = sprintf( $message, number_format_i18n( $untrashed ) );
    249264    $_SERVER['REQUEST_URI'] = remove_query_arg(array('untrashed'), $_SERVER['REQUEST_URI']);
    250265}
  • trunk/src/wp-admin/users.php

    r31696 r31941  
    217217<h2><?php _e('Delete Users'); ?></h2>
    218218<?php if ( isset( $_REQUEST['error'] ) ) : ?>
    219 <div class="error">
    220     <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
    221 </div>
     219    <div class="error">
     220        <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
     221    </div>
    222222<?php endif; ?>
    223 <p><?php echo _n( 'You have specified this user for deletion:', 'You have specified these users for deletion:', count( $userids ) ); ?></p>
     223
     224<?php if ( 1 == count( $userids ) ) : ?>
     225    <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
     226<?php else : ?>
     227    <p><?php _e( 'You have specified these users for deletion:' ); ?></p>
     228<?php endif; ?>
     229
    224230<ul>
    225231<?php
     
    237243    </ul>
    238244<?php if ( $go_delete ) : ?>
    239     <fieldset><p><legend><?php echo _n( 'What should be done with content owned by this user?', 'What should be done with content owned by these users?', $go_delete ); ?></legend></p>
     245    <?php if ( 1 == $go_delete ) : ?>
     246        <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
     247    <?php else : ?>
     248        <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
     249    <?php endif; ?>
    240250    <ul style="list-style:none;">
    241251        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
     
    380390        case 'del_many':
    381391            $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
    382             $messages[] = '<div id="message" class="updated"><p>' . sprintf( _n( 'User deleted.', '%s users deleted.', $delete_count ), number_format_i18n( $delete_count ) ) . '</p></div>';
     392            if ( 1 == $delete_count ) {
     393                $message = __( 'User deleted.' );
     394            } else {
     395                $message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
     396            }
     397            $messages[] = '<div id="message" class="updated"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
    383398            break;
    384399        case 'add':
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r31698 r31941  
    13521352        $num_locations  = count( array_keys( $locations ) );
    13531353
     1354        if ( 1 == $num_locations ) {
     1355            $description = __( 'Your theme supports one menu. Select which menu you would like to use.' );
     1356        } else {
     1357            $description = sprintf( _n( 'Your theme supports %s menu. Select which menu appears in each location.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) );
     1358        }
     1359
    13541360        $this->add_section( 'nav', array(
    13551361            'title'          => __( 'Navigation' ),
    13561362            'theme_supports' => 'menus',
    13571363            'priority'       => 100,
    1358             'description'    => sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'),
     1364            'description'    => $description . "\n\n" . __( 'You can edit your menu content on the Menus screen in the Appearance section.' ),
    13591365        ) );
    13601366
  • trunk/src/wp-includes/theme-compat/comments.php

    r30754 r31941  
    2424
    2525<?php if ( have_comments() ) : ?>
    26     <h3 id="comments"><?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number() ),
    27                                     number_format_i18n( get_comments_number() ), '&#8220;' . get_the_title() . '&#8221;' ); ?></h3>
     26    <h3 id="comments">
     27        <?php
     28            if ( 1 == get_comments_number() ) {
     29                printf( 'One Response to %2$s',  '&#8220;' . get_the_title() . '&#8221;' );
     30            } else {
     31                printf( _n( '%1$s Response to %2$s', '%1$s Responses to %2$s', get_comments_number() ),
     32                    number_format_i18n( get_comments_number() ),  '&#8220;' . get_the_title() . '&#8221;' );
     33            }
     34        ?>
     35    </h3>
    2836
    2937    <div class="navigation">
Note: See TracChangeset for help on using the changeset viewer.