您可以连接到Wordpress的翻译过滤器来更改任何单词或短语。这些过滤器包括:gettext
, ngettext
和gettext_with_context
:
add_filter(\'gettext\', \'change_bbpress_wording\', 10, 3);
add_filter(\'ngettext\', \'change_bbpress_wording\', 10, 3);
add_filter(\'gettext_with_context\', \'change_bbpress_wording\', 10, 3);
function change_bbpress_wording ($translated, $untranslated, $domain) {
if ($domain == \'bbpress\') {
$translated = str_ireplace(\'Forum\', \'*desired word*\', $translated );
$translated = str_ireplace(\'Topic\', \'*desired word*\', $translated );
$translated = str_ireplace(\'Reply\', \'*desired word*\', $translated );
}
return $translated;
}
请注意,我们使用
str_ireplace
不区分大小写,用于区分大小写的替换
str_replace
相反
看见gettext filter hook 有关更多示例,请参阅codex页。