I developed a small plugin that adds (or to be more precise: first deletes then adds again) some custom user roles. Each of these roles is set up in a way like this:
function wpdev_141551_add_role_someone() {
$role = 'someone';
remove_role( $role );
$capabilities = array(
'read' => TRUE,
'publish_posts' => TRUE,
'edit_posts' => TRUE,
'delete_posts' => FALSE,
// ...
);
add_role( $role, 'Someone', $capabilities );
}
Now the problem is, these custom user roles don't get translated at all.
The translations of the default user roles (Author, Contributor etc.) are included in WordPress's default text domain. So how/where should I step in and translate these custom role names?
If I add the role with a gettext call for its name __( 'Someone', 'plugin-text-domain' )
then the string that gets written to the database will be translated according to the current language. What I would like to have, however, is a solution that lets me switch languages as I want and have the roles be displayed accordingly—without having to de- and then reactivate the plugin (i.e., delete and add the role, again).
I will post my current solution to this, but I'm still very interested in any other (possibly more efficient) approach.
add_role( $role, __('Someone', 'text-domain'), $capabilities );
but then you deleted it... so what's wrong there?