
WordPress函数文件Functions.php教程指南
_nx_noop ( $singular, $plural, $context, $domain = null )
_nx_noop: 此函数用于翻译一个带有单数和复数形式以及上下文的字符串,而不对其进行回声。
在POT文件中用gettext上下文注册复数字符串,但不对其进行翻译。
当你想保留带有可翻译的复数字符串的结构并在以后知道数字时使用它们时使用。
通过上下文参数消除歧义的通用短语的例子:
$messages = array(
‘people’ => _nx_noop( ‘%s group’, ‘%s groups’, ‘people’, ‘text-domain’ ),
‘animals’ => _nx_noop( ‘%s group’, ‘%s groups’, ‘animals’, ‘text-domain’ ),
);
…
$message = $messages[ $type ];
printf( translate_nooped_plural( $message, $count, ‘text-domain’ ), number_format_i18n( $count ) );
function _nx_noop( $singular, $plural, $context, $domain = null ) { return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain, ); }