Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Fetching also translations with Storefront API Graphql Endpoint

Solved

Fetching also translations with Storefront API Graphql Endpoint

ptrck_schndr
Shopify Partner
11 0 11

We are using the Storefront API to fetch more than 50 products at once on the Products QueryRoot Object with an array of IDs. This runs very smooth and fast, so no problem here. We have also translated product data with the Admin Translation API by a self-made custom app which fetches products from an ERP automatically. Runs smooth too, so there is also no problem here.

BUT – if we use the i18n language codes to switch the translations in the URL, e.g. from https://supershop.com to https://supershop.com/fr and then using the /api/graphl endpoint, it still gives us the standard language data from the product and NOT the translated french language data.

Is there any possibility that the endpoint recognizes that I am doing my request from a translated shop url?

Accepted Solution (1)

c10s
Shopify Partner
67 12 27

This is an accepted solution.

Replies 4 (4)

c10s
Shopify Partner
67 12 27

This is an accepted solution.

Try adding an Accept-Language header to the request, as documented here: https://shopify.dev/tutorials/support-multiple-languages-with-storefront-api#retrieving-storefront-a...

ptrck_schndr
Shopify Partner
11 0 11

Thanks, this did the trick!

pierrealexis
Visitor
3 0 0

This solution doesn't work anymore since the documentation have changed 

For me event after getting multiples languages with localization none of them work if I use @inContext(language: ES) for exemple

mfirghi
Shopify Partner
4 0 0

Any update on this? it is still not working for me