qTranslate-Team / woocommerce-qtranslate-x

Enables multilingual framework for plugin "WooCommerce - excelling eCommerce".
GNU General Public License v3.0
11 stars 19 forks source link

Product archive description not translated #2

Closed soft79 closed 9 years ago

soft79 commented 9 years ago

WooCommerce fetches the archive content this way:

wc-template-functions.php function woocommerce_product_archive_description():

$shop_page   = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
    $description = wc_format_content( $shop_page->post_content );
    if ( $description ) {
        echo '<div class="page-description">' . $description . '</div>';
    }
}

If displayed by the theme, you see the [:en]raw[:] content.

changing WooCommerce to do it this way fixes the issue: $description = wc_format_content( apply_filters('the_content', $shop_page->post_content) );

but can it be fixed by adding some kind of hook in WooCommerce qTranslate X ?

johnclause commented 9 years ago

Hi @josk79, I could not find an existent filter to enable for this case so far. Could you test on your configuration, to change function in woocommerce/includes/wc-formatting-functions.php

function wc_format_content( $string ) { return do_shortcode( shortcode_unautop( wpautop( $string ) ) ); }

as this

function wc_format_content( $string ) { return apply_filters('woocommerce_format_content', do_shortcode( shortcode_unautop( wpautop( $string ) ) )); }

and then add 'woocommerce_format_content' to the array $use_filters in woocommerce-qtranslate-x/qwc-front.php.

If this works well for you, submit this change to https://github.com/woothemes/woocommerce, they are friendly on new filters and their next release will have it.

johnclause commented 9 years ago

Actually, when you submit to Woocommerce, this version would be more flexible, just in case:

function wc_format_content( $string ) { $w=wpautop( $string ); $s=shortcode_unautop( $w ); return apply_filters('woocommerce_format_content', do_shortcode($s), $string, $w, $s); }

soft79 commented 9 years ago

I made a copy/paste error in the solution in the first post, just fixed it.

What do you think about this: wc_format_content( apply_filters('the_content', $shop_page->post_content) );

johnclause commented 9 years ago

This they may oppose, since it may have an effect on others.

johnclause commented 9 years ago

It is safe to make a change that does nothing to the current users, otherwise they will be hesitant. A new filter at that place would be fine, but I think my version is more advantageous to us and possibly to others since it provides a common flexibility.

johnclause commented 9 years ago

Besides, there might be other uses of wc_format_content, including their future development, which we have not caught yet, but some day somebody will ;)

soft79 commented 9 years ago

Yes you're right. That makes sense...

soft79 commented 9 years ago

Closed in https://github.com/woothemes/woocommerce/commit/09bee8ccb23cfe1f5625f82b69a24aabf1c05dc9