I'm using WooCommerce for a site that I'm currently working on. And I'm creating it for a language other than English. I do the translations by means of the .po file.

The issue that I'm encountering is in the Checkout page. There is a table of order review which upon page loaded seems to be refreshed by means of AJAX call. Before the call the texts are all translated. But after the call the texts all reverted back to their original language (ie. English).

How do I retain the translation after the AJAX call?

enter image description here

  • Are you using a multilingual plugin like qTranslate or WPML?
    – cybmeta
    Feb 2, 2014 at 9:41
  • @cybnet: No, I only use Backend Localization plugin to retain the backend in English. For the frontend I configure define('WPLANG', 'id_ID'); in wp-config.php. (kau-boys.com/230/wordpress/kau-boys-backend-localization-plugin)
    – Giraldi
    Feb 2, 2014 at 11:11
  • 1
    This is likely plugin's issue or limitation. Had you tried inquiring with its developer?
    – Rarst
    Feb 2, 2014 at 13:51
  • @Rarst: Not yet. I guess I should've tried inquiring them first, huh? I had assumed it was a WP issue.
    – Giraldi
    Feb 3, 2014 at 0:39
  • @Rarst: Okay, I had contacted them (WooCommerce) but they claim it's not the fault of the plugin but my setup. So what setup am I missing to translate an AJAX generated content?
    – Giraldi
    Feb 4, 2014 at 1:34

3 Answers 3


I think I fixed the issue with the following extended function in my plugin:

function localize_backend( $locale ) {
    // set langauge if user is in admin area
    if( defined( 'WP_ADMIN' ) || ( isset( $_REQUEST['pwd'] ) && isset( $_REQUEST['kau-boys_backend_localization_language'] ) ) ){
        // ajax call from frontend
        if ( 'admin-ajax.php' == basename( $_SERVER[ 'SCRIPT_FILENAME' ] ) && strpos( admin_url(), $_SERVER[ 'HTTP_REFERER' ] ) === false ) {
            // if lang request param was set, change locale for AJAX response, else, don't overwrite locale (use frontend locale)
            if ( ! empty( $_REQUEST[ 'lang' ] ) ) {
                $locale = $_REQUEST[ 'lang' ];
        } else {
            $locale = backend_localization_get_locale();

    return $locale;

It will check if an AJAX call was made. If the call was coming from the frontend, it checks for a lang request param. If one could be found, it set's the $locale to this value. Otherwise it doesn't changes the locale to be backend setting, so it should be the locale from the frontend, defined in the wp-config.phpfile.

Please update to version 2.1 of the plugin and check again.

Thanks again for @Rarst and @cybnet for their hints.

  • Awesome! It works! Thank you! And thanks also to Rarst & @cybnet for the tips!
    – Giraldi
    Feb 27, 2014 at 4:34

You have differents languages in your site, although your frontend is not multilingual, you serve one language in frontend and another in backend. Ajax in Wordpress is processed in the "admin area" (wp-admin/admin-ajax.php), so the reponse of an ajax request will be in the language defined in the admin area. "English" in your case.

I don't know exactly how the plugin "Backend localization" works but other plugins that affect to the language need a language parameter in the ajax request. For example, to make qTranslate working in ajax, the lang param has to be added to the ajaxurl value in the javascript, something like ajaxurl+'?lang=es'. You will need to contact to developer of "Backend localization"

  • Great, changing the admin po-file actually solved the issue for me! I should prefer this solution before the other fix.
    – jtheman
    Apr 25, 2014 at 11:42
  • Thank you! I've been struggling with this issue for too long! I just ended up adding some code to functions.php and now it works! Here's the code: add_filter("wc_checkout_params", 'translate_ajax'); function translate_ajax($params) { $params["ajax_url"] = $params["ajax_url"]."?lang=".qtrans_getLanguage(); return $params; } Feb 13, 2015 at 1:08

Another possible fix is to add:

$is_ajax = true; 

at line 11 in an override version of review-order.php, which should be copied from:




Not the answer you're looking for? Browse other questions tagged or ask your own question.