- 状态
- 未解决
- 报告针对
- WPML Multilingual & Multicurrency for WooCommerce 5.3.9
- 主题标签
- Bug, WCML
问题概述
WPML Multilingual & Multicurrency for WooCommerce在单一产品页面的“评价”选项卡下显示时,可以正确翻译产品评价。但是,当使用 WooCommerce 的评价区块时,不会显示已翻译的评价。相反,显示的是原始语言的评价。
临时解决方法
在继续操作之前,请确保为您的站点创建完整的站点备份。
- 打开主题的 functions.php 文件。
- 添加以下代码片段:
add_filter( 'get_comment', 'translate_comment' ); function translate_comment( $comment ){ if ( !is_singular('product') && isset( $comment->comment_type ) && $comment->comment_type === 'review' && isset( $comment->comment_content ) ) { $name = 'product-'.$comment->comment_post_ID.'-review-'.$comment->comment_ID; $comment->comment_content = apply_filters( 'wpml_translate_single_string', $comment->comment_content, 'wcml-reviews', $name ); } return $comment; }