_c() – Retrieve translated string with vertical bar context

You appear to be a bot. Output may be restricted

Description

Retrieve translated string with vertical bar context

Quite a few times, there will be collisions with similar translatable text found in more than two places but with different translated context. In order to use the separate contexts, the _c() function is used and the translatable string uses a pipe ('|') which has the context the string is in. When the translated string is returned, it is everything before the pipe, not including the pipe character. If there is no pipe in the translated text then everything is returned.

Usage

$string = _c( $text, $domain );

Parameters

$text
( string ) required – Text to translate.
$domain
( string ) optional default: default – Optional. Domain to retrieve the translated text.

Returns

string Translated context string without pipe.

Source

File name: wordpress/wp-includes/deprecated.php
Lines:

1 to 4 of 4
function _c( $text, $domain = 'default' ) {
  _deprecated_function( _c, '2.9.0', '_x()' );
  return before_last_bar( translate( $text, $domain ) );
}
 

 View on GitHub View on Trac