translate_user_role

Translates role name.

Description

(string) translate_user_role( (string) $name ); 

Since the role names are in the database and not in the source there are dummy gettext calls to get them into the POT file and this function properly translates them back.

The before_last_bar() call is needed, because older installs keep the roles using the old context format: Role name|User role and just skipping the content after the last bar is easier than fixing them in the DB. New installs won't suffer from that problem.

Returns (string)

Translated role name on success, original name on failure.

Parameters (1)

0. $name (string)
The role name.

Usage

  1. if ( !function_exists( 'translate_user_role' ) ) { 
  2. require_once ABSPATH . WPINC . '/l10n.php'; 
  3.  
  4. // The role name. 
  5. $name = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = translate_user_role($name); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/l10n.php  
  1. function translate_user_role( $name ) { 
  2. return translate_with_gettext_context( before_last_bar($name), 'User role' );