Custom product translation / multiple languages / Next.js custom storefront

Solved
Donfetto
New Member
1 0 0

Hallo world,

I am building a custom Storefront with next.js using the vercel commerce kit.

I added custom product translations using the shopify app Translate My Store.

Querying the translation in the graphiql App works just fine:

 

 

  productByHandle(handle: $slug) {
    id
    handle
    title
    translations(locale: $locale) {
      key
      value
      locale
    }
  }

 

 

And the result:

 

{
  "data": {
    "productByHandle": {
      "id": "gid://shopify/Product/6726839238806",
      "handle": "kinder-t-shirt",
      "title": "Kinder T-shirt",
      "translations": [
        {
          "key": "title",
          "value": "Camiseta blanca",
          "locale": "es"
        }
      ]
    }
  }

 

 

But if I send a graphql request from my next.js app it crashes, showing this error: Error: Field 'translations' doesn't exist on type 'Product'

 

 

productByHandle(handle: $slug) {
      translations(locale: "es") {
        key
        value
        locale
      }
      id
      handle
      title
    }

 

 

 

 

I am able to get all the other product information I need. Why I am not able to receive the translations?

Only querying translations won't work.

 

Thanks for your help.

 

0 Likes
davidgg
Tourist
4 1 2

This is an accepted solution.

You're using different API's, I think.

 

 

When querying the Storefront you've to add a Header with the locale like this

Accept-Language: en

 

0 Likes