App reviews, troubleshooting, and recommendations
Is it possible to get product data in different languages via API ?
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
}
}
}
}
}
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.
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).
Transform this holiday season into a shopping spree. Plus, learn how to effortlessly open ...
By Jasonh Dec 8, 2023Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023