diff --git a/wp-admin/includes/list-table-comments.php b/wp-admin/includes/list-table-comments.php index 5f5255c40b..76ce9320b6 100644 --- a/wp-admin/includes/list-table-comments.php +++ b/wp-admin/includes/list-table-comments.php @@ -149,7 +149,7 @@ class WP_Comments_Table extends WP_List_Table { $link = add_query_arg( 's', esc_attr( stripslashes( $_REQUEST['s'] ) ), $link ); */ $status_links[$status] = "
  • " . sprintf( - _n( $label[0], $label[1], $num_comments->$status ), + translate_nooped_plural( $label, $num_comments->$status ), number_format_i18n( $num_comments->$status ) ) . ''; } diff --git a/wp-admin/includes/list-table-media.php b/wp-admin/includes/list-table-media.php index ff08d254a7..dcd9b72d53 100644 --- a/wp-admin/includes/list-table-media.php +++ b/wp-admin/includes/list-table-media.php @@ -67,7 +67,7 @@ class WP_Media_Table extends WP_List_Table { if ( !empty($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) $class = ' class="current"'; if ( !empty( $num_posts[$mime_type] ) ) - $type_links[$mime_type] = "
  • " . sprintf( _n( $label[2][0], $label[2][1], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; + $type_links[$mime_type] = "
  • " . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . ''; } $type_links['detached'] = '
  • ' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . ''; diff --git a/wp-admin/includes/list-table-posts.php b/wp-admin/includes/list-table-posts.php index 07015292a9..188e04aae1 100644 --- a/wp-admin/includes/list-table-posts.php +++ b/wp-admin/includes/list-table-posts.php @@ -170,7 +170,7 @@ class WP_Posts_Table extends WP_List_Table { if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) $class = ' class="current"'; - $status_links[$status_name] = "
  • " . sprintf( _n( $status->label_count[0], $status->label_count[1], $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . ''; + $status_links[$status_name] = "
  • " . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . ''; } if ( ! empty( $this->sticky_posts_count ) ) { diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index d3935a2747..5ead282a13 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -1863,7 +1863,7 @@ foreach ( $post_mime_types as $mime_type => $label ) { if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) $class = ' class="current"'; - $type_links[] = "
  • $mime_type, 'paged'=>false))) . "'$class>" . sprintf(_n($label[2][0], $label[2][1], $num_posts[$mime_type]), "" . number_format_i18n( $num_posts[$mime_type] ) . '') . ''; + $type_links[] = "
  • $mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "" . number_format_i18n( $num_posts[$mime_type] ) . '') . ''; } echo implode(' |
  • ', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . ''; unset($type_links); diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php index 4e76d3d87a..922ff2e96b 100644 --- a/wp-includes/l10n.php +++ b/wp-includes/l10n.php @@ -267,15 +267,15 @@ function _nx($single, $plural, $number, $context, $domain = 'default') { * ); * ... * $message = $messages[$type]; - * $usable_text = sprintf(_n($message[0], $message[1], $count), $count); + * $usable_text = sprintf( translate_nooped_plural( $message, $count ), $count ); * * @since 2.5 * @param string $single Single form to be i18ned * @param string $plural Plural form to be i18ned * @return array array($single, $plural) */ -function _n_noop( $single, $plural ) { - return array( $single, $plural ); +function _n_noop( $singular, $plural ) { + return array( 'singular' => $singular, 'plural' => $plural, 'context' => null ); } /** @@ -283,8 +283,23 @@ function _n_noop( $single, $plural ) { * * @see _n_noop() */ -function _nx_noop( $single, $plural, $context ) { - return array( $single, $plural, $context ); +function _nx_noop( $singular, $plural, $context ) { + return array( 'singular' => $singular, 'plural' => $plural, 'context' => $context ); +} + +/** + * Translate the result of _n_noop() or _nx_noop() + * + * @since 3.1 + * @param array $nooped_plural array with singular, plural and context keys, usually the result of _n_noop() or _nx_noop() + * @param int $count number of objects + * @param string $domain Optional. The domain identifier the text should be retrieved in + */ +function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { + if ( $nooped_plural['context'] ) + return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); + else + return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain ); } /**