If the products and variants inside the ajax cart do not translate, then probably the theme's js does not connect to the correct endpoint of Shopify's Ajax API.


This can be fixed by adding the root_url to the url of the API.


Open the themes .js files (eg: theme.js.liquid) and search for occurrences of "/cart" like this:


When you find hardcoded URLs like above, you would have to add the request.locale.root_url to the API source.

As some liquid objects are not available in js files, you can use langify's locale object to get the root_url of the current language.

var root_url = window.langify.locale.root_url != '/' ? window.langify.locale.root_url : '';


Include the above snippet into the code like this:


Now your ajax-cart should translate.


The described workaround can be applied to all endpoints of the Shopify Ajax API:

  • /products/<product-handle>.js
  • /cart/add.js
  • /cart.js
  • /cart/update.js
  • /cart/change.js
  • /cart/clear.js
  • /cart/shipping_rates.json
  • /recommendations/products.json?product_id=<product-id>

Troubleshooting


If you have applied the above fix and the ajax-cart does not translate nevertheless, you should ensure that the theme doesn't load a minimized version of the js file you have edited (in most cases the theme.js.liquid).


If you should have control over the js file minification process, it is recommended to generate a new theme.min.js with your code changes and leaving the theme.liquid as it is.


Check the theme.liquid if it includes a minimized file version like here:


You then can just remove the .min from the related include (eg: "{{ 'theme.js' | asset_url  }}" ).