【发布时间】:2018-12-23 16:42:50
【问题描述】:
默认情况下,WooCommerce 在单个产品视图下方显示相关产品时使用“相关产品”一词。
我希望更改这些词,并用我的客户喜欢的文本来补充它。
/wp-content/plugins/woocommerce/i18n/languages/woocommerce.pot
#: templates/single-product/rating.php:42
msgid "%s customer review"
msgid_plural "%s customer reviews"
msgstr[0] ""
msgstr[1] ""
#: templates/single-product/related.php:51
msgid "Related Products"
msgstr ""
#: templates/single-product/review-meta.php:28
msgid "Your comment is awaiting approval"
msgstr ""
到
#: templates/single-product/related.php:51
msgid "Related Products"
msgstr "Customers who rented this item also rented:"
我也尝试在第 12 行附近编辑 wp-content/plugins/woocommerce/templates/single-product/related.php 文件。
来自
<h2><?php esc_html_e( 'Related products', 'woocommerce' ); ?></h2>
到
<h2><?php esc_html_e( 'Customers who rented this item also rented:', 'woocommerce' ); ?></h2>
我还将这段代码添加到 function.php 文件中:
function custom_related_products_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related products' :
$translated_text = __( 'Customers who rented this item also rented:', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'custom_related_products_text', 20, 3 );
但它似乎不起作用
<h2><?php esc_html_e( 'Customers who rented this item also rented:', 'woocommerce' ); ?></h2>
msgid "Related Products"
msgstr "Customers who rented this item also rented:"
function custom_related_products_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Related products' :
$translated_text = __( 'Customers who rented this item also rented:', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'custom_related_products_text', 20, 3 );
相关产品文字应该改为
租用此项目的客户也租用了:
【问题讨论】:
标签: php wordpress woocommerce product gettext