question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-Shopify Translations | How to get products in a second language from Shopify

See original GitHub issue

Hello everyone. I’m trying to get products in the second language from Shopify store.

The Storefront API states that the HTTP request header must contain Accept-Language: de, in my case (in React), the settings should look like this: https://shopify.dev/tutorials/manage-app-translations-with-admin-api#storefront-api-translation-header

const clientWithTranslatedContent = Client.buildClient({
  domain: 'your-shop-name.myshopify.com',
  storefrontAccessToken: 'your-storefront-access-token',
  language: 'de' // Accept-Language
});

How it have to work you can find here: https://github.com/Shopify/js-buy-sdk/blob/update-language-setting/src/client.js

I’m using Shopify Webhook API version 2020-07 (Latest). Here https://github.com/gatsbyjs/gatsby/issues/24173#issuecomment-646820211 I found information that in version 2020-04 Accept-Language header supports translations, but it doesn’t work in my case.

In building an application, I always receive goods with default translation (EN).

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
mattia85commented, Apr 16, 2021

Would love to know more about this as well…

Sure, these are the steps to reproduce the problem.

  1. Add a second language to your Shopify (under Settings > Store Languages).
  2. Translate some product fields using langify application or using the Shopify api.
  3. Inside you frontend create the shopify-buy client passing the language code (no the default one).
const shopifyBuyClient = Client.buildClient({
  domain: 'your-shop-name.myshopify.com',
  storefrontAccessToken: 'your-storefront-access-token',
  language: 'it-IT'
});
  1. Add the translated product inside the cart using shopifyBuyClient
  2. Take a look to the checkout object returned from the addLineItems call, the products fields inside lineItems array are not translated.

I hope it’s clear now. Thank you.

3reactions
a5okolcommented, Oct 2, 2020

The problem was caused by the “gatsby-source-shopify” plugin that generates pages in gatsby-node.js. It doesn’t take into account Accept-Language in the header of HTTP requests. To solve the problem, my team has finalized this plugin.

Here’s a link: https://github.com/alex-borodin-vtlabs/gatsby-source-shopify-translated

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Shopify Translations | How to get products in a ...
I want to display Products data in 2 languages. Can I use Shopify Storefront API to fetch Translation on the storefront? – Arslan...
Read more >
Managing languages
Visit the Shopify App Store and install a translation app to your store. Follow the steps in the app to translate your online...
Read more >
Localization and translation
Localize and translate your online store for international customers. ... To sell in multiple languages, you need to have the following:.
Read more >
How To Use Translation Keys To Create Internationalized ...
If for example, you wanted the default language to be French, you would name your French locale file fr.default.json . Find your new...
Read more >
Translating and localizing your store
You can't translate product URLs. Product URLs remain in the language that they were created in, even when a customer views your site...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found