看看来源,你已经知道了。:)
我没有,但我打赌有一段代码是这样的:
_e( \'Activity\', \'buddypress\' );
…或…
__( \'Activity\', \'buddypress\' );
遵循函数,它们是函数的包装器
translate()
在里面
wp-includes/l10n.php
:
/**
* Retrieves the translation of $text. If there is no translation, or
* the domain isn\'t loaded, the original text is returned.
*
* @see __() Don\'t use translate() directly, use __()
* @since 2.2.0
* @uses apply_filters() Calls \'gettext\' on domain translated text
* with the untranslated text as second parameter.
*
* @param string $text Text to translate.
* @param string $domain Domain to retrieve the translated text.
* @return string Translated text
*/
function translate( $text, $domain = \'default\' ) {
$translations = &get_translations_for_domain( $domain );
return apply_filters( \'gettext\', $translations->translate( $text ), $text, $domain );
}
您会看到一个过滤器:
\'gettext\'
有三个参数(或参数)。现在可以使用过滤器更改输出
将此添加到主题的
functions.php
或插件:
add_filter(
\'gettext\', // filter name
\'wpse_57673_change_buddypress_profile_tabs\', // name of your custom function
10, // priority
3 // number of arguments you want to get
);
现在我们需要自定义函数,这非常简单:
function wpse_57673_change_buddypress_profile_tabs( $translated, $original_text, $domain )
{
if ( \'buddypress\' !== $domain )
{
return $translated; // not your text
}
// find the text to change
switch ( $original_text )
{
case \'Activity\':
return \'My Activity\';
case \'Groups\':
return \'My Groups\';
default:
return $translated;
}
}