For some reason in edit-user.php I have to do a checkbox list of user roles. I got it but I have a problem of translation.

My code

<?php foreach ( $roles as $role_id => $role_data ) : ?>
      <label for="user_role_<?php echo esc_attr( $role_id ); ?>">
          <input type="checkbox" id="user_role_<?php echo esc_attr( $role_id ); ?>" class="h4a-user-role-checkbox" value="<?php echo esc_attr( $role_id ); ?>" name="h4a_user_roles[]"<?php echo in_array( $role_id, $user_roles ) ? ' checked="checked"' : ''; ?> />
          echo translate_user_role( $role_data['name'] );
      <br />
<?php endforeach; ?>

The problem is if I add a "plugin text domain", I don´t know it for roles from others plugins.

Is there a way to get all translations ?

  • (Repost) There isn't a standard way to get all the translations (from all plugins) and one should always specify the text domain when retrieving a translation. (Exception to the 'default' domain) And you could actually just use your own text domain or the 'default' one, and add translations to that domain for the different role names - for example, you can do that easily using Loco Translate. – Sally CJ Jun 16 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.