New Shopify Certification now available: Liquid Storefronts for Theme Developers

Get product translations via API

resboss
Shopify Partner
25 0 4

Is it possible to get product data in different languages via API ?

Replies 2 (2)
magecomp
Shopify Partner
255 19 28

Hello @resboss 

 

You will need to use the @inContext directive. The @inContext the directive allows you to specify the language that you want to retrieve product data in. For example, the following query will retrieve product data in French:

 
{
  products(first: 10, reverse: true) {
    edges {
      node {
        id
        translations(locale: "fr") {
          key
          locale
          value
        }
      }
    }
  }
}
The translations object will contain all of the translations for the product, including the title, description, and options. The locale property will indicate the language of the translation.

You can also use the Accept-Language HTTP header to specify the language that you want to retrieve product data in. For example, the following request will retrieve product data in the language of the user's browser:

 
curl -X GET \
  -H "Accept-Language: fr" \
  "https://my-store.myshopify.com/admin/api/2022-04/products.json" \
  -H "X-Shopify-Access-Token: xxxxx"
 

The Shopify API will return the product data in the language that you specified.

Helping voluntarily. Please like and accept the solution if it helps. Thanks!
Our Bestseller Shopify Apps    |      Mobile App Builder by MageComp    |      Limit Qty Purchase

Need a developer?  Just visit MageComp website
remy727
Shopify Partner
40 2 19

 

You can create a translation using translationsRegister (requires write_translations access_scope).

You can retrieve the translation content of the product using translatableResource (requires read_translations access_scope). 

Looking for a Shopify App developer? Please visit: https://github.com/remy727