qTranslate + WooCommerce ajax translation issue

Today i was working on a new WordPress project which needed multilingual support. I looked up and the best free plugin that came up was qTranslate. I really love the plugin because it provides out of the box support for many other plugins since it translates the same way the default translation works in WordPress.

I had to implement it with WooCommerce and there was no surprise that all the shop pages were being translated as desired.

But, there was one issue. Everytime there was an ajax process, the returning HTML would come back non-translated and in default language. i.e English.

So after hours of digging up the internet and code, i found out that the content was not being translated because there was no language parameter being passed on to the Ajax calls.

To rectify this i thought of appending the current language to the ajax url. After some digging i found out the following code in plugins/woocommerce/woocommerce.php and edited it to append the current language.



Of course you should extend the Woocommerce class to avoid overwrite of file upon plugin update.



Application developer, movie buff, occasional reader and a huge Manchester United fan.
  • Damian

    That helped me a lot. You are genius!

  • Frank Zhang

    but qtrans_getLanguage can’t be support in this file, and even I hard code there such as admin-ajax.php?lang=zh, it still respond in default language.