Translating content for an online store

For this tutorial, you'll use the GraphQL Admin API to enable the es locale on your store, retrieve a product, and then translate the product's title. Finally, you'll publish the new locale and view the translated content on your store.


This tutorial has the following requirements:

Step 1: Install the Shopify GraphiQL App

Install the Shopify GraphiQL app on your store. You can use the Shopify GraphiQL app to build and execute GraphQL queries and mutations on your store. When installing the GraphiQL app, make sure that you enable the translations and locales write access scope.

Step 2: Enable a locale

Use the shopLocaleEnable mutation to enable the es locale on your store. In the shopLocale response, include the locale, name, and published fields to verify that the locale has been successfully enabled.

By default, newly enabled locales are not published.

Run in GraphiQL

Step 3: Retrieve a translatable product

To retrieve the first product eligible for translation, use the translatableResources query with the parameters first: 1 and resourceType: PRODUCT. In the translatableContent response, include the key, value, digest, and locale fields. You need their response values to write the translation in the next step.

Run in GraphiQL

Step 4: Write a translation

Use the translationsRegister mutation to create a new translation for a translatable resource. When you create a translation, you need to include the translatable content's digest value in the translatableContentDigest field. A unique digest is returned from the translatableResources query for each translatableContent entry.

Run in GraphiQL

Note: Replace the value of id with the value of resourceId from the product that you queried in step 3.

Step 5: Publish the loca