gettext contexts. Props nbachiyski. see #9112

git-svn-id: http://svn.automattic.com/wordpress/trunk@10767 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-03-10 23:02:29 +00:00
parent 2f4b8b8566
commit d10b538652
12 changed files with 59 additions and 31 deletions

View File

@ -790,7 +790,7 @@ function wp_edit_posts_query( $q = false ) {
'publish' => array(__('Published'), __('Published posts'), _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')),
'future' => array(__('Scheduled'), __('Scheduled posts'), _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')),
'pending' => array(__('Pending Review'), __('Pending posts'), _n_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>')),
'draft' => array(__('Draft'), _c('Drafts|manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),
'draft' => array(__('Draft'), _x('Drafts', 'manage posts header'), _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')),
'private' => array(__('Private'), __('Private posts'), _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')),
);

View File

@ -363,17 +363,22 @@ function populate_roles_160() {
// Add roles
// Dummy gettext calls to get strings in the catalog.
_c('Administrator|User role');
_c('Editor|User role');
_c('Author|User role');
_c('Contributor|User role');
_c('Subscriber|User role');
/* translators: user role */
_x('Administrator', 'User role');
/* translators: user role */
_x('Editor', 'User role');
/* translators: user role */
_x('Author', 'User role');
/* translators: user role */
_x('Contributor', 'User role');
/* translators: user role */
_x('Subscriber', 'User role');
add_role('administrator', 'Administrator|User role');
add_role('editor', 'Editor|User role');
add_role('author', 'Author|User role');
add_role('contributor', 'Contributor|User role');
add_role('subscriber', 'Subscriber|User role');
add_role('administrator', 'Administrator');
add_role('editor', 'Editor');
add_role('author', 'Author');
add_role('contributor', 'Contributor');
add_role('subscriber', 'Subscriber');
// Add caps for Administrator role
$role =& get_role('administrator');

View File

@ -763,7 +763,7 @@ function wp_manage_media_columns() {
/* translators: column name */
$posts_columns['media'] = _x('File', 'column name');
$posts_columns['author'] = __('Author');
//$posts_columns['tags'] = _c('Tags|media column header');
//$posts_columns['tags'] = _x('Tags', 'column name');
/* translators: column name */
$posts_columns['parent'] = _x('Attached to', 'column name');
$posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
@ -1892,7 +1892,7 @@ function user_row( $user_object, $style = '', $role = '' ) {
} else {
$edit = '<strong>' . $user_object->user_login . '</strong>';
}
$role_name = isset($wp_roles->role_names[$role]) ? translate_with_context($wp_roles->role_names[$role]) : __('None');
$role_name = isset($wp_roles->role_names[$role]) ? translate_user_role($wp_roles->role_names[$role] ) : __('None');
$r = "<tr id='user-$user_object->ID'$style>";
$columns = get_column_headers('users');
$hidden = get_hidden_columns('users');
@ -2679,7 +2679,7 @@ function wp_dropdown_roles( $selected = false ) {
$editable_roles = get_editable_roles();
foreach( $editable_roles as $role => $details ) {
$name = translate_with_context($details['name']);
$name = translate_user_role($details['name'] );
if ( $selected == $role ) // Make default first in list
$p = "\n\t<option selected='selected' value='$role'>$name</option>";
else

View File

@ -94,14 +94,16 @@ function wp_install_defaults($user_id) {
// Default category
$cat_name = __('Uncategorized');
$cat_slug = sanitize_title(_c('Uncategorized|Default category slug'));
/* translators: Default category slug */
$cat_slug = sanitize_title(_x('Uncategorized', 'Default category slug'));
$wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '1', 'taxonomy' => 'category', 'description' => '', 'parent' => 0, 'count' => 1));
// Default link category
$cat_name = __('Blogroll');
$cat_slug = sanitize_title(_c('Blogroll|Default link category slug'));
/* translators: Default link category slug */
$cat_slug = sanitize_title(_x('Blogroll', 'Default link category slug'));
$wpdb->insert( $wpdb->terms, array('name' => $cat_name, 'slug' => $cat_slug, 'term_group' => 0) );
$wpdb->insert( $wpdb->term_taxonomy, array('term_id' => '2', 'taxonomy' => 'link_category', 'description' => '', 'parent' => 0, 'count' => 7));
@ -168,7 +170,8 @@ function wp_install_defaults($user_id) {
'post_excerpt' => '',
'post_title' => __('Hello world!'),
'post_category' => 0,
'post_name' => _c('hello-world|Default post slug'),
/* translators: Default post slug */
'post_name' => _x('hello-world', 'Default post slug'),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,
@ -199,7 +202,8 @@ function wp_install_defaults($user_id) {
'post_excerpt' => '',
'post_title' => __('About'),
'post_category' => '',
'post_name' => _c('about|Default page slug'),
/* translators: Default page slug */
'post_name' => _x('about', 'Default page slug'),
'post_modified' => $now,
'post_modified_gmt' => $now_gmt,
'guid' => $first_post_guid,

View File

@ -173,7 +173,7 @@ if ($allowed_files) :
<li><a href="theme-editor.php?file=<?php echo "$template_file"; ?>&amp;theme=<?php echo urlencode($theme) ?>"><?php echo $filedesc ?></a></li>
<?php endwhile; ?>
</ul>
<h4><?php echo _c('Styles|Theme stylesheets in theme editor'); ?></h4>
<h4><?php /* translators: Theme stylesheets in theme editor */ echo _x('Styles', 'Theme stylesheets in theme editor'); ?></h4>
<ul>
<?php
$template_mapping = array();

View File

@ -276,8 +276,9 @@ foreach ( $wp_roles->get_names() as $this_role => $name ) {
$class = ' class="current"';
}
$name = translate_with_context($name);
$name = sprintf( _c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $avail_roles[$this_role] );
$name = translate_user_role( $name );
/* translators: User role name with count */
$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, $avail_roles[$this_role] );
$role_links[] = "<li><a href='users.php?role=$this_role'$class>$name</a>";
}
echo implode( " |</li>\n", $role_links) . '</li>';

View File

@ -49,7 +49,7 @@ if ( post_password_required($commentstatus) ) { // and it doesn't match the coo
<?php foreach ($comments as $comment) { ?>
<li id="comment-<?php comment_ID() ?>">
<?php comment_text() ?>
<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
<p><cite><?php comment_type(_x('Comment', 'noun'), __('Trackback'), __('Pingback')); ?> <?php _e("by"); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite></p>
</li>
<?php } // end for each comment ?>

View File

@ -21,7 +21,7 @@ if ( post_password_required() ) : ?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
<?php echo get_avatar( $comment, 32 ); ?>
<?php comment_text() ?>
<p><cite><?php comment_type(_c('Comment|noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
<p><cite><?php comment_type(_x('Comment', 'noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?> &#8212; <?php comment_date() ?> @ <a href="#comment-<?php comment_ID() ?>"><?php comment_time() ?></a></cite> <?php edit_comment_link(__("Edit This"), ' |'); ?></p>
</li>
<?php endforeach; ?>

View File

@ -252,8 +252,10 @@ function get_comments( $args = '' ) {
function get_comment_statuses( ) {
$status = array(
'hold' => __('Unapproved'),
'approve' => _c('Approved|adjective'),
'spam' => _c('Spam|adjective'),
/* translators: comment status */
'approve' => _x('Approved', 'adjective'),
/* translators: comment status */
'spam' => _x('Spam', 'adjective'),
);
return $status;

View File

@ -2214,9 +2214,12 @@ function wp_sprintf_l($pattern, $args) {
// Translate and filter the delimiter set (avoid ampersands and entities here)
$l = apply_filters('wp_sprintf_l', array(
'between' => _c(', |between list items'),
'between_last_two' => _c(', and |between last two list items'),
'between_only_two' => _c(' and |between only two list items'),
/* translators: used between list items, there is a space after the coma */
'between' => __(', '),
/* translators: used between list items, there is a space after the and */
'between_last_two' => __(', and '),
/* translators: used between only two list items, there is a space after the and */
'between_only_two' => __(' and '),
));
$args = (array) $args;

View File

@ -179,7 +179,7 @@ desc:"' . mce_escape( __('Insert page break.') ) . '"
}}});
tinyMCE.addI18n("' . $language . '.advanced",{
style_select:"' . mce_escape( __('Styles') ) . '",
style_select:"' . mce_escape( /* translators: TinyMCE font styles */ _x('Styles', 'TinyMCE font styles') ) . '",
font_size:"' . mce_escape( __('Font size') ) . '",
fontdefault:"' . mce_escape( __('Font family') ) . '",
block:"' . mce_escape( __('Format') ) . '",

View File

@ -176,7 +176,7 @@ function __ngettext() {
function _n($single, $plural, $number, $domain = 'default') {
$translations = &get_translations_for_domain( $domain );
$translation = $translations->translate_plural( $single, $plural, $number );
return apply_filters( 'ngettext', $translation, $single, $plural, $number );
return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
}
/**
@ -191,7 +191,7 @@ function _nc( $single, $plural, $number, $domain = 'default' ) {
function _nx($single, $plural, $number, $context, $domain = 'default') {
$translations = &get_translations_for_domain( $domain );
$translation = $translations->translate_plural( $single, $plural, $number, $context );
return apply_filters( 'ngettext_with_context ', $translation, $single, $plural, $number, $context );
return apply_filters( 'ngettext_with_context ', $translation, $single, $plural, $number, $context, $domain );
}
/**
@ -340,4 +340,17 @@ function get_translations_for_domain( $domain ) {
return isset($l10n[$domain])? $l10n[$domain] : $empty;
}
/**
* Translates role name. Since the role names are in the database and
* not in the source there are dummy gettext calls to get them into the POT
* file and this function properly translates them back.
*
* The before_last_bar() call is needed, because older installs keep the roles
* using the old context format: 'Role name|User role' and just skipping the
* content after the last bar is easier than fixing them in the DB. New installs
* won't suffer from that problem.
*/
function translate_user_role( $name ) {
return before_last_bar( translate_with_gettext_context( $name, 'User role' ) );
}
?>