Opened 11 years ago
Closed 8 years ago
#2501 closed defect (bug) (fixed)
bbPress Roles Names not translated in role view selector line of Users Admin Page
Reported by: | rwatuny | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.6 | Priority: | normal |
Severity: | normal | Version: | 2.5.1 |
Component: | Locale - i18n/l10n | Keywords: | |
Cc: |
Description
I found a little translation bug in bbPress 2.5.2 and earlier:
in the Users Admin page (wp-admin/users.php), the role view selector line that contains
All | Administrator | Editor ...
contains untranslated bbPress roles.
For exemple, in French we see :
Tous (#) | Administrateur (#) | Éditeur (#) | Contributeur (#) | Abonné (#) | Keymaster (#) | Moderator (#) | Participant (#)
I tracked the problem:
In wp-admin/users.php, the line used to display the role view selector line is
$wp_list_table->views();
The views() function seems to get its value from get_views() in wp-admin/includes/class-wp-users-list-table.php where the role name is translated with use of
$name = translate_user_role( $name );
The translate_user_role function is defined in wp-includes/l10n.php as
function translate_user_role( $name ) {
return translate_with_gettext_context( before_last_bar($name), 'User role' );
}
The translate_with_gettext_context, also defined in wp-includes/l10n.php uses the default WordPress domain.
A solution (a bit patchy) might be to add a gettext_with_context filter in the setup_actions function with its corresponding function in the bbpress/includes/admin/users.php file.
add_filter( 'gettext_with_context', array( $this, 'user_role_view_selector' ), 10, 4 );
public static function user_role_view_selector( $translations, $text, $context, $domain ) {
if ( ( 'User role' == $context ) and ( 'default' == $domain ) and ( $translations == $text ) ) {
return translate( $text, 'bbpress' );
} else {
return $translations;
}
}
Note: the conditions i.e. ( 'User role' == $context ) and ( 'default' == $domain ) and ( $translations == $text ) are to make sure we do not overwrite other translations.
I created a plugin with the above code and it works.
Change History (5)
#5
@
8 years ago
- Milestone changed from 2.7 to 2.6
- Resolution set to fixed
- Status changed from new to closed
I'm seeing the following for Spanish:
Todos (3) | Administrador (1) | Suscriptor (2) | Super administrador (1) | Espectador (1) | Participante (1)
On the user edit page, e.g. http://src.wordpress-develop.dev/wp-admin/user-edit.php?user_id=2
Going to close this and mark it as fixed as I can no longer reproduce the issue.
Thanks for this, and sorry for the inconvenience. I'll make sure this is fixed in 2.6.