WPML
ステータス
未解決
報告対象
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;
    }

すべての既知の問題 →