translate_with_context

Definition:
function translate_with_context( $text, $domain = 'default' ) {}

Translates $text like translate(), but assumes that the text contains a context after its last vertical bar.

Parameters

  • string $text: Text to translate
  • string $domain: Domain to retrieve the translated text

Return values

returns:Translated text

Source code

function translate_with_context( $text, $domain = 'default' ) {

	_deprecated_function( __FUNCTION__, '2.9', '_x()' );

	return before_last_bar( translate( $text, $domain ) );

}

3089

translate_user_role

Definition:
function translate_user_role( $name ) {}

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 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.

Parameters

  • $name

Source code

function translate_user_role( $name ) {

	return translate_with_gettext_context( before_last_bar($name), 'User role' );

}

3087

translate_smiley

Definition:
function translate_smiley($smiley) {}

Convert one smiley code to the icon graphic file equivalent.
Looks up one smiley code in the $wpsmiliestrans global array and returns an <img> string for that smiley.

Parameters

  • string $smiley: Smiley code to convert to image.

Return values

returns:Image string for smiley.

Defined filters

  • smilies_src
    apply_filters('smilies_src', includes_url("images/smilies/$img")

Source code

function translate_smiley($smiley) {

	global $wpsmiliestrans;



	if (count($smiley) == 0) {

		return '';

	}



	$smiley = trim(reset($smiley));

	$img = $wpsmiliestrans[$smiley];

	$smiley_masked = esc_attr($smiley);



	$srcurl = apply_filters('smilies_src', includes_url("images/smilies/$img"), $img, site_url());



	return " <img src='$srcurl' alt='$smiley_masked' class='wp-smiley' /> ";

}

3085

translate_level_to_role

Definition:
function translate_level_to_role($level) {}

Translate user level to user role name.

Parameters

  • int $level: User level.

Return values

returns:User role name.

Source code

function translate_level_to_role($level) {

	switch ($level) {

	case 10:

	case 9:

	case 8:

		return 'administrator';

	case 7:

	case 6:

	case 5:

		return 'editor';

	case 4:

	case 3:

	case 2:

		return 'author';

	case 1:

		return 'contributor';

	case 0:

		return 'subscriber';

	}

}

3083

translate

Definition:
function translate( $text, $domain = 'default' ) {}

Retrieves the translation of $text. If there is no translation, or the domain isn’t loaded, the original text is returned.

Parameters

  • string $text: Text to translate.
  • string $domain: Domain to retrieve the translated text.

Return values

returns:Translated text

Defined filters

  • gettext
    apply_filters( 'gettext', $translations->translate( $text )

Source code

function translate( $text, $domain = 'default' ) {

	$translations = &get_translations_for_domain( $domain );

	return apply_filters( 'gettext', $translations->translate( $text ), $text, $domain );

}

3081