下面是一个示例,其中使用gettext
过滤器:
/**
* Translate a certain string from a particular text domain.
*
* @param string $translation Translated text.
* @param string $text Text to translate.
* @param string $domain Text domain. Unique identifier for retrieving translated strings.
*
* @return string
*/
add_filter( \'gettext\', \'wpse_translate_string\', 10, 3 );
function wpse_translate_string( $translation, $text, $domain ) {
if ( \'plugin_text_domain\' === $domain ) {
if ( \'Original string...\' === $text ) {
$translation = \'New string!\';
}
}
return $translation;
}