Storefront API and multiple languages

Tourist
12 0 1

Hi,

 

I'm building a storefront in react.js using the Shopify Storefront API. Everything has been setup to work with the base store, including pulling collections, products and cart interactions. However, the site is multi lingual (two languages), and I need the shopify products, collections and checkout to reflect that. 

 

Is this possible? And if so, how can I do this? 

0 Likes
Community Manager
Community Manager
618 45 81

Hey @malthemilthers,

 

I believe I answered your question here: https://community.shopify.com/c/Shopify-APIs-SDKs/New-Translation-API-is-available-from-which-API-ve...

 

TLDR: the translation API is only available in our admin API currently.

0 Likes
Highlighted
Tourist
12 0 1

Right thank you,

 

So i just need to clarify that it's not possible in anyway to serve translated storefront API data. Even if you combine the two APIs? 

 

Sorry for running this in two threads. probably more appropriate to continue here. 

0 Likes
Community Manager
Community Manager
618 45 81

No problem! Yea, let's stick to this thread for now.

 

There's no way to serve translated storefront API data currently. You could potentially come up with a solution using different products for each different translation, but it would be a workaround for sure.

 

Translation support for our storefront API is something we'll definitely be exploring in the near future, so stay tuned.

0 Likes
Tourist
12 0 1

Alright, 

 

It definitely feels like a necessary step towards headless e-commerce to be able to translate product data, so that the products in cart reflects the chosen language. None of the Shopify translation apps deals with issue as far as I can tell. They only work with regular Shopify themes. 

 

One more question: how is it possible to translate product information via the admin API, when it's not possible via the admin itself? It doesn't seem possible to fill out title and description etc in different languages for the same product. Is that also something that is likely to become natively available in Shopify in the near future? 

 

Thank you! 

0 Likes
Community Manager
Community Manager
618 45 81

Hi again @malthemilthers,

 

The plan is for translations to be served by the API initially. Native translation fields are a possibility in the future, but the opportunity will be given to our app ecosystem initially regardless of the direction we go after.

0 Likes
Tourist
4 0 2

I ran into the same problem since I have to build a headless multilang store using nextjs.
But there is a workaround, you can make your shop a multilang json endpoint if you let liquid render json

theme.json.liquid (you have to leave in some of original content in comment-tag because shopify validates their tags to be in)

{{ content_for_layout }}
{% comment %}
<!doctype html>
<html class="no-js" lang="{{ shop.locale }}">
...
{% endcomment %}

product.json.liquid

{% layout 'theme.json' %}
{{ product | json }}

now under /de/products/my-product you have a the my-product populated in json with german translations.

For the cart you can fetch /de/cart.js for translated cart contents.

I don't know if this is the preferred shopify solution, but on the other hand it doesn't make sense to me building translations into the backend but not make them available in the frontend apis

 

2 Likes
Tourist
12 0 1

i Devkai,

 

Does that also work for the checkout pages? Are you able to get the product titles translated in the checkout flow?

 

I agree. I'm baffled that multi-language is not a build in feature in Shopify. Also baffled that no other platform have taken that market yet. Can't believe we're stuck with hacks and workarounds for this stuff in 2020, unless we build the whole thing from scratch. 

0 Likes
Tourist
4 0 2

puh for the checkout I have no headless-hack, I'm going to use the shopify checkout.

0 Likes
Tourist
12 0 1
Right so produkt titles will still me one language only in checkout, correct?
0 Likes