Shortcode to show author role on the author archive page

You can use the main WP_Roles object to get an array of role names/labels, e.g.

$role="author";
$label=""; // if there is no label this will be used instead
if ( wp_roles()->has_role( $role ) ) { // this protects us if the role does not exist.
    $role_names = wp_roles()->get_names();
    $label = $role_names[$role]; // Author
}
echo $label; // prints Author not author

translate_user_role will translate it into the currently configured locale if available.

Here’s the output of get_names():

wp> wp_roles()->get_names();
=> array(14) {
  ["administrator"]=>
  string(13) "Administrator"
  ["editor"]=>
  string(6) "Editor"
  ["author"]=>
  string(6) "Author"
  ["contributor"]=>
  string(11) "Contributor"
  ["subscriber"]=>
  string(10) "Subscriber"
....

tech