• Resolved shelomovskiy

    (@shelomovskiy)


    Hi there,

    I’m runing a multilingual version of wordpress+woocommerce eshop. So my reports are being sent in two languages (czech and english). While it’s all good for Czech language on default domain (www.diypraha.cz) it does not translate product names (everything else looks fine) for the English subdomain generated orders (en.diypraha.cz) so it looks like this leaving qTranslate tags in the text: [:CZ]?lenství pro ob?asné
    hobíky[:en]Occassional User[:]

    Do you know what I can do about it?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Bas Elbers

    (@baaaaas)

    WooCommerce PDF Invoices Premium supports multilangual while the free version does not.
    You can shoot me an email if you would like to try the WooCommerce PDF Invoices Premium.

    This can be quite easily fixed if you create a custom template for the invoice.
    I added a few lines to the template body.php to make sure that product information is translated using the qtranslate-X filter ‘translate_text’. Depending on the version you will find the comment
    // Get attribute data
    around line 107. This is the new code:

    // Get attribute data.
    if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
       // Changes by Christer: Make sure product info is translated here
       $my_locale = explode('_', get_locale())[0]; // ** added
       $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
       $meta['meta_key']   = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
       $meta['meta_key'] = apply_filters('translate_text',$meta['meta_key'], $my_locale) ; // ** added
       $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
       $meta['meta_value'] = apply_filters('translate_text',$meta['meta_value'], $my_locale) ; // ** added
    } else {
       $meta['meta_key'] = apply_filters( 'woocommerce_attribute_label', wc_attribute_label( $meta['meta_key'], $product ), $meta['meta_key'] );
       $meta['meta_key'] = apply_filters('translate_text',$meta['meta_key'], $my_locale) ; // ** added
    ...					}
    
    Thread Starter shelomovskiy

    (@shelomovskiy)

    Thank you very much Christer, will try it tonight.

    Joe

    (@wizzoratek)

    Can someone please tell me how to include the product name and the customer name in the invoice – as I’m trying to customize it into a PDF Certificate

    Woops! You need to translate the meta_value in the else-part also, by adding one more line. It should be:

    
    // Get attribute data.
    if ( taxonomy_exists( wc_sanitize_taxonomy_name( $meta['meta_key'] ) ) ) {
       // Changes by Christer: Make sure product info is translated here
       $my_locale = explode('_', get_locale())[0]; // ** added
       $term = get_term_by( 'slug', $meta['meta_value'], wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
       $meta['meta_key']   = wc_attribute_label( wc_sanitize_taxonomy_name( $meta['meta_key'] ) );
       $meta['meta_key'] = apply_filters('translate_text',$meta['meta_key'], $my_locale) ; // ** added
       $meta['meta_value'] = isset( $term->name ) ? $term->name : $meta['meta_value'];
       $meta['meta_value'] = apply_filters('translate_text',$meta['meta_value'], $my_locale) ; // ** added
    } else {
       $meta['meta_key'] = apply_filters( 'woocommerce_attribute_label', wc_attribute_label( $meta['meta_key'], $product ), $meta['meta_key'] );
       $meta['meta_key'] = apply_filters('translate_text',$meta['meta_key'], $my_locale) ; // ** added
       $meta['meta_value'] = apply_filters('translate_text',$meta['meta_value'], $my_locale) ; // ** added
    ...
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Multi language site’ is closed to new replies.