public static function getCatalogStrings()
{
return [
'booking_appointment' => __('Booking Appointment', 'wpamelia'),
'buffer_time' => __('Buffer Time', 'wpamelia'),
'categories' => __('Categories', 'wpamelia'),
'category_colon' => __('Category:', 'wpamelia'),
'description' => __('Description', 'wpamelia'),
'description_colon' => __('Description:', 'wpamelia'),
'extras' => __('Extras', 'wpamelia'),
'info' => __('Info', 'wpamelia'),
'maximum_quantity_colon' => __('Maximum Quantity:', 'wpamelia'),
'view_more' => __('View More', 'wpamelia'),
];
}
Above code is written in plugin. I want to write 'Book now' instead of 'View More' through function.php without editting plugin.
以上代码是用插件编写的。我想通过function.php编写“立即预订”而不是“查看更多”,而无需编辑插件。
答案 0 :(得分:1)
使用gettext过滤器。
示例:
function prefix_filter_gettext( $translated, $original, $domain ) {
if ( $domain == 'wpamelia' ){
// Use the text string exactly as it is in the translation file
if ( $translated == 'View More' ) {
$translated = 'Book now';
}
}
return $translated;
}
add_filter( 'gettext', 'prefix_filter_gettext', 10, 3 );