theme-scripts icon indicating copy to clipboard operation
theme-scripts copied to clipboard

theme-cart - Product translations

Open brechtwaeghe opened this issue 4 years ago • 1 comments

At the moment the request to the cart.js doesn't fetch the translated content of the products such as the title. Would it be possible to prefix the request url with the current root url?

For example when you translate your shop to French the root url will be /fr. The ajax request to /cart.js fetches the products in the default language. The products will be translated when you change the request to /fr/cart.js.

As a side note this should be mentioned in the docs as well: https://shopify.dev/docs/themes/ajax-api/reference/cart

brechtwaeghe avatar Jul 17 '20 15:07 brechtwaeghe

We’ve implemented this in our theme by setting the current cart routes on a global theme object in theme.liquid and reading them in this script, like this:

https://gist.github.com/nikitaourazbaev/134aba47ab10cf373487ae090ea25545

Not sure if it’s too specific a solution, happy to open a PR if this is fine.

nikitaourazbaev avatar Apr 19 '21 13:04 nikitaourazbaev