Ticket #3442: translate_roles.diff
File translate_roles.diff, 4.4 KB (added by , 16 years ago) |
---|
-
wp-includes/l10n.php
74 74 } 75 75 76 76 /** 77 * translate_with_context() - Retrieve the translated text and strip context 78 * 79 * If the domain is set in the $l10n global, then the text is run 80 * through the domain's translate method. After it is passed to 81 * the 'gettext' filter hook, along with the untranslated text as 82 * the second parameter. 83 * 84 * If the domain is not set, the $text is just returned. 85 * 86 * @since 2.5 87 * @uses translate() 88 * 89 * @param string $text Text to translate 90 * @param string $domain Domain to retrieve the translated text 91 * @return string Translated text 92 */ 93 function translate_with_context($text, $domain) { 94 $whole = translate($text, $domain); 95 $last_bar = strrpos($whole, '|'); 96 if ( false == $last_bar ) { 97 return $whole; 98 } else { 99 return substr($whole, 0, $last_bar); 100 } 101 } 102 103 /** 77 104 * __() - Retrieve a translated string 78 105 * 79 106 * __() is a convenience function which retrieves the translated … … 130 157 * @return string Translated context string without pipe 131 158 */ 132 159 function _c($text, $domain = 'default') { 133 $whole = translate($text, $domain); 134 $last_bar = strrpos($whole, '|'); 135 if ( false == $last_bar ) { 136 return $whole; 137 } else { 138 return substr($whole, 0, $last_bar); 139 } 160 return translate_with_context($text, $domain); 140 161 } 141 162 142 163 /** -
wp-admin/users.php
263 263 if ( $role == $_GET['role'] ) 264 264 $class = ' class="current"'; 265 265 266 $name = translate_with_context($name); 266 267 $name = sprintf(_c('%1$s (%2$s)|user role with count'), $name, $avail_roles[$role]); 267 268 $role_links[] = "<li><a href=\"users.php?role=$role\"$class>" . $name . '</a>'; 268 269 } -
wp-admin/includes/schema.php
267 267 268 268 function populate_roles_160() { 269 269 // Add roles 270 add_role('administrator', _c('Administrator|User role'));271 add_role('editor', _c('Editor|User role'));272 add_role('author', _c('Author|User role'));273 add_role('contributor', _c('Contributor|User role'));274 add_role('subscriber', _c('Subscriber|User role'));275 270 271 // Dummy gettext calls to get strings in the catalog. 272 _c('Administrator|User role'); 273 _c('Editor|User role'); 274 _c('Author|User role'); 275 _c('Contributor|User role'); 276 _c('Subscriber|User role'); 277 278 add_role('administrator', 'Administrator|User role'); 279 add_role('editor', 'Editor|User role'); 280 add_role('author', 'Author|User role'); 281 add_role('contributor', 'Contributor|User role'); 282 add_role('subscriber', 'Subscriber|User role'); 283 276 284 // Add caps for Administrator role 277 285 $role = get_role('administrator'); 278 286 $role->add_cap('switch_themes'); -
wp-admin/includes/template.php
545 545 } else { 546 546 $edit = $user_object->user_login; 547 547 } 548 $role_name = translate_with_context($wp_roles->role_names[$role]); 548 549 $r = "<tr id='user-$user_object->ID'$style> 549 550 <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' /></td> 550 551 <td><strong>$edit</strong></td> 551 552 <td>$user_object->first_name $user_object->last_name</td> 552 553 <td><a href='mailto:$email' title='" . sprintf( __('e-mail: %s' ), $email ) . "'>$email</a></td> 553 <td> {$wp_roles->role_names[$role]}</td>";554 <td>$role_name</td>"; 554 555 $r .= "\n\t\t<td>"; 555 556 if ( $numposts > 0 ) { 556 557 $r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>"; … … 891 892 function wp_dropdown_roles( $default = false ) { 892 893 global $wp_roles; 893 894 $r = ''; 894 foreach( $wp_roles->role_names as $role => $name ) 895 foreach( $wp_roles->role_names as $role => $name ) { 896 $name = translate_with_context($name); 895 897 if ( $default == $role ) // Make default first in list 896 898 $p = "\n\t<option selected='selected' value='$role'>$name</option>"; 897 899 else 898 900 $r .= "\n\t<option value='$role'>$name</option>"; 901 } 899 902 echo $p . $r; 900 903 } 901 904