Uses
Uses | Description |
---|---|
wp-includes/l10n.php: translate_with_gettext_context() | Retrieve the translation of $text in the context defined in $context. |
wp-includes/l10n.php: before_last_bar() | Remove last item on a pipe-delimited string. |
Translates role 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 installations 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 installations won’t suffer from that problem.
(string) (Required) The role name.
(string) (Optional) Text domain. Unique identifier for retrieving translated strings.
Default value: 'default'
(string) Translated role name on success, original name on failure.
File: wp-includes/l10n.php
function translate_user_role( $name, $domain = 'default' ) { return translate_with_gettext_context( before_last_bar( $name ), 'User role', $domain ); }
Version | Description |
---|---|
5.2.0 | Added the $domain parameter. |
2.8.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/translate_user_role