重命名Woocommerce 3中的相关产品标题 [英] Rename Related Products title in Woocommerce 3
本文介绍了重命名Woocommerce 3中的相关产品标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾经具有以下功能,可以在Woocommerce中更改为相关产品"文本.
I used to have the following function working to change to Related Products text in Woocommerce.
function my_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related Products' :
$translated_text = __( 'Related Books', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'my_text_strings', 20, 3 );
它始终可以完美运行,但是从Woocommerce 3.0或更高版本开始,此功能不再起作用.
It always worked perfectly, but as of Woocommerce version 3.0 or so, this function no longer works.
我应该如何解决此问题,以使其在3.0版及更高版本中正常工作?
How should I fix this in order to make it working in the version 3.0 and up?
推荐答案
尝试一下,它与我合作
add_filter( 'gettext', 'wps_translate_words_array' );
add_filter( 'ngettext', 'wps_translate_words_array' );
function wps_translate_words_array( $translated ) {
$words = array(
// 'word to translate' = > 'translation'
'Related Products' => 'Check out these related products',
);
$translated = str_ireplace( array_keys($words), $words, $translated );
return $translated;
}
这篇关于重命名Woocommerce 3中的相关产品标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文