• Resolved gerardciclick

    (@gerardciclick)


    Hi Charlie,

    I can’t find where to translate the text label using WPML. Isn’t that possible?
    Thank you very much.

    Gerard.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Charlie Etienne

    (@charlieetienne)

    Hi @gerardciclick,

    Unfortunately, this plugin isn’t compatible with WPML yet.

    If you can wait, I will look for a solution soon. Or you can use Polylang instead of WPML which should be compatible.

    Regards,

    Charlie

    Thread Starter gerardciclick

    (@gerardciclick)

    Hi @charlieetienne ,

    Thank you very much. This time we will make a custom change to allow text translation, and we appreciate if in the future it can be changed from WPML.

    Thanks for your quick response!

    Gerard

    Plugin Author Charlie Etienne

    (@charlieetienne)

    Hi Gerard,

    Could you help me to make this available to everyone?

    Follow these steps:

    1. go to /wp-content/plugins/sold-out-badge-for-woocommerce/ directory
    2. Create a new file called wpml-config.xml inside this directory
    3. Inside that xml file, paste the following:

    
    <wpml-config>
      <custom-fields>
        <custom-field action="translate" style="line" label="Badge label">_wcsob_text</custom-field>
      </custom-fields>
    </wpml-config>
    

    Tell me if it works, it would really help me!

    Thanks,

    Charlie

    Thread Starter gerardciclick

    (@gerardciclick)

    Hi Charlie,

    It didn’t work for me. After creating the wpml-config.xml file I scanned the plugin from WPML > Theme and plugins localization, but no record appeared in WPML > String translation.

    I have managed to translate it using the __() function in /wp-content/plugins/sold-out-badge-for-woocommerce/woocommerce/single-product/sold-out.php :
    <?php echo apply_filters( 'wcsob_soldout', '<span class="wcsob_soldout">' . __('Sold out','sold-out-badge-for-woocommerce') . '</span>', $post, $product ); ?>
    But I am not sure if this is a correct method.

    Thank you very much for your attention.

    Gerard

    Plugin Author Charlie Etienne

    (@charlieetienne)

    Hi @gerardciclick, I just published a new version with WPML compatibility (4.2.0).

    Could you try and let me know?

    Thanks.

    PS: the main problem of your solution is you can’t update the plugin without losing your changes. A better way is to use hooks. For example, here, you could have done the following in functions.php:

    
    add_filter( 'wcsob_soldout', function($content, $post, $product){
        return '<span class="wcsob_soldout">' . __('Sold out','sold-out-badge-for-woocommerce') . '</span>';
    });
    
    Thread Starter gerardciclick

    (@gerardciclick)

    Thank you very much! I have installed the new version (4.2.0) and it works now.

    I knew I couldn’t update the plugin if I modified the source files, but I didn’t know the proper way. Thanks for your time.

    Gerard.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Translate label with WPML’ is closed to new replies.