ngettext fixes from nbachiyski. fixes #6261

git-svn-id: http://svn.automattic.com/wordpress/trunk@7397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-19 16:00:09 +00:00
parent 6acfc685e6
commit c66438659d
10 changed files with 49 additions and 23 deletions

View File

@ -97,7 +97,7 @@ if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['sp
<?php
$status_links = array();
$num_comments = wp_count_comments();
$stati = array('moderated' => sprintf(__('Awaiting Moderation (%s)'), "<span class='comment-count'>$num_comments->moderated</span>"), 'approved' => __('Approved'));
$stati = array('moderated' => sprintf(__ngettext('Awaiting Moderation (%s)', 'Awaiting Moderation (%s)', $num_comments->moderated), "<span class='comment-count'>$num_comments->moderated</span>"), 'approved' => _c('Approved|plural'));
$class = ( '' === $comment_status ) ? ' class="current"' : '';
$status_links[] = "<li><a href=\"edit-comments.php\"$class>".__('Show All Comments')."</a>";
foreach ( $stati as $status => $label ) {

View File

@ -36,11 +36,11 @@ $parent_file = 'edit.php';
wp_enqueue_script('admin-forms');
$post_stati = array( // array( adj, noun )
'publish' => array(__('Published'), __('Published pages'), __('Published (%s)')),
'future' => array(__('Scheduled'), __('Scheduled pages'), __('Scheduled (%s)')),
'pending' => array(__('Pending Review'), __('Pending pages'), __('Pending Review (%s)')),
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), _c('Draft (%s)|manage posts header')),
'private' => array(__('Private'), __('Private pages'), __('Private (%s)'))
'publish' => array(__('Published'), __('Published pages'), __ngettext_noop('Published (%s)', 'Published (%s)')),
'future' => array(__('Scheduled'), __('Scheduled pages'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
'pending' => array(__('Pending Review'), __('Pending pages'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
'private' => array(__('Private'), __('Private pages'), __ngettext_noop('Private (%s)', 'Private (%s)'))
);
$post_status_label = __('Manage Pages');
@ -93,7 +93,7 @@ foreach ( $post_stati as $status => $label ) {
$class = ' class="current"';
$status_links[] = "<li><a href=\"edit-pages.php?post_status=$status\"$class>" .
sprintf($label[2], $num_posts->$status) . '</a>';
sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), $num_posts->$status) . '</a>';
}
echo implode(' |</li>', $status_links) . '</li>';
unset($status_links);

View File

@ -97,7 +97,7 @@ foreach ( $post_stati as $status => $label ) {
$class = ' class="current"';
$status_links[] = "<li><a href=\"edit.php?post_status=$status\"$class>" .
sprintf($label[2], $num_posts->$status) . '</a>';
sprintf(__ngettext($label[2][0], $label[2][1], $num_posts->$status), $num_posts->$status) . '</a>';
}
echo implode(' |</li>', $status_links) . '</li>';
unset($status_links);

View File

@ -225,7 +225,7 @@ class Dotclear_Import {
// Store category translation for future use
add_option('dccat2wpcat',$dccat2wpcat);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
return true;
}
echo __('No Categories to Import!');

View File

@ -269,12 +269,12 @@ class GM_Import {
}
if ($numAddedComments > 0) {
echo ': ';
printf(__('imported %s'), sprintf( __ngettext('%s comment', '%s comments', $numAddedComments) , $numAddedComments) );
printf( __ngettext('imported %s comment', 'imported %s comments', $numAddedComments) , $numAddedComments);
}
$preExisting = $numComments - numAddedComments;
if ($preExisting > 0) {
echo ' ';
printf(__('ignored %s'), sprintf( __ngettext( '%s pre-existing comment', '%s pre-existing comments', $preExisting ) , $preExisting) );
printf( __ngettext( 'ignored %s pre-existing comment', 'ignored %s pre-existing comments', $preExisting ) , $preExisting);
}
}
echo '... <strong>'.__('Done').'</strong></li>';

View File

@ -177,7 +177,7 @@ class Textpattern_Import {
// Store category translation for future use
add_option('txpcat2wpcat',$txpcat2wpcat);
echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
return true;
}
echo __('No Categories to Import!');

View File

@ -992,7 +992,7 @@ foreach ( $post_mime_types as $mime_type => $label ) {
if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
$class = ' class="current"';
$type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf($label[2], "<span id='$mime_type-counter'>{$num_posts[$mime_type]}</span>") . '</a>';
$type_links[] = "<li><a href='" . add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false)) . "'$class>" . sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='$mime_type-counter'>{$num_posts[$mime_type]}</span>") . '</a>';
}
echo implode(' | </li>', $type_links) . '</li>';
unset($type_links);

View File

@ -519,11 +519,11 @@ function wp_edit_posts_query( $q = false ) {
$q['m'] = (int) $q['m'];
$q['cat'] = (int) $q['cat'];
$post_stati = array( // array( adj, noun )
'publish' => array(__('Published'), __('Published posts'), __('Published (%s)')),
'future' => array(__('Scheduled'), __('Scheduled posts'), __('Scheduled (%s)')),
'pending' => array(__('Pending Review'), __('Pending posts'), __('Pending Review (%s)')),
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), _c('Draft (%s)|manage posts header')),
'private' => array(__('Private'), __('Private posts'), __('Private (%s)'))
'publish' => array(__('Published'), __('Published posts'), __ngettext_noop('Published (%s)', 'Published (%s)')),
'future' => array(__('Scheduled'), __('Scheduled posts'), __ngettext_noop('Scheduled (%s)', 'Scheduled (%s)')),
'pending' => array(__('Pending Review'), __('Pending posts'), __ngettext_noop('Pending Review (%s)', 'Pending Review (%s)')),
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), __ngettext_noop('Draft (%s)', 'Drafts (%s)')),
'private' => array(__('Private'), __('Private posts'), __ngettext_noop('Private (%s)', 'Private (%s)')),
);
$post_stati = apply_filters('post_stati', $post_stati);
@ -568,9 +568,9 @@ function wp_edit_attachments_query( $q = false ) {
$q['post_type'] = 'attachment';
$q['post_status'] = 'any';
$post_mime_types = array( // array( adj, noun )
'image' => array(__('Images'), __('Manage Images'), __('Images (%s)')),
'audio' => array(__('Audio'), __('Manage Audio'), __('Audio (%s)')),
'video' => array(__('Video'), __('Manage Video'), __('Video (%s)')),
'image' => array(__('Images'), __('Manage Images'), __ngettext_noop('Image (%s)', 'Images (%s)')),
'audio' => array(__('Audio'), __('Manage Audio'), __ngettext_noop('Audio (%s)', 'Audio (%s)')),
'video' => array(__('Video'), __('Manage Video'), __ngettext_noop('Video (%s)', 'Video (%s)')),
);
$post_mime_types = apply_filters('post_mime_types', $post_mime_types);

View File

@ -98,7 +98,7 @@ foreach ( $post_mime_types as $mime_type => $label ) {
$class = ' class="current"';
$type_links[] = "<li><a href=\"upload.php?post_mime_type=$mime_type\"$class>" .
sprintf($label[2], $num_posts[$mime_type]) . '</a>';
sprintf(__ngettext($label[2][0], $label[2][1], $num_posts[$mime_type]), $num_posts[$mime_type]) . '</a>';
}
echo implode(' | </li>', $type_links) . '</li>';
unset($type_links);

View File

@ -195,6 +195,32 @@ function __ngettext($single, $plural, $number, $domain = 'default') {
}
}
/**
* __ngettext_noop() - register plural strings in POT file, but don't translate them
*
* Used when you want do keep structures with translatable plural strings and
* use them later.
*
* Example:
* $messages = array(
* 'post' => ngettext_noop('%s post', '%s posts'),
* 'page' => ngettext_noop('%s pages', '%s pages')
* );
* ...
* $message = $messages[$type];
* $usable_text = sprintf(__ngettext($message[0], $message[1], $count), $count);
*
* @since 2.5
* @param $single Single form to be i18ned
* @param $plural Plural form to be i18ned
* @param $number Not used, here for compatibility with __ngettext, optional
* @param $domain Not used, here for compatibility with __ngettext, optional
* @return array array($single, $plural)
*/
function __ngettext_noop($single, $plural, $number=1, $domain = 'default') {
return array($single, $plural);
}
/**
* load_textdomain() - Loads MO file into the list of domains
*
@ -296,4 +322,4 @@ function load_theme_textdomain($domain) {
load_textdomain($domain, $mofile);
}
?>
?>