wc_translate_user_roles( string $translation, string $text, string $context, string $domain )

Translate WC roles using the woocommerce textdomain.


Description Description


Parameters Parameters

$translation

(Required) Translated text.

$text

(Required) Text to translate.

$context

(Required) Context information for the translators.

$domain

(Required) Text domain. Unique identifier for retrieving translated strings.


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/wc-user-functions.php

function wc_translate_user_roles( $translation, $text, $context, $domain ) {
	// translate_user_role() only accepts a second parameter starting in WP 5.2.
	if ( version_compare( get_bloginfo( 'version' ), '5.2', '<' ) ) {
		return $translation;
	}

	if ( 'User role' === $context && 'default' === $domain && in_array( $text, array( 'Shop manager', 'Customer' ), true ) ) {
		return translate_user_role( $text, 'woocommerce' );
	}

	return $translation;
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.7.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.