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
shopLocaleEnable mutation to enable the
es locale on your store. In the
shopLocale response, include the
published fields to verify that the locale has been successfully enabled.
By default, newly enabled locales are not published.
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
locale fields. You need their response values to write the translation in the next step.
Step 4: Write a translation
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
Note: Replace the value of
idwith the value of
resourceIdfrom the product that you queried in step 3.