Support multiple languages on storefronts

You can use the Storefront API to support multiple languages on a storefront. This tutorial explains how to retrieve translated content with the Storefront API.

Requirements

Translatable resources

The following resources include properties that can be retrieved by using the Storefront API:

Type Fields
Collection title, descriptionHtml, description
Metafield value
Article title, content, contentHtml, excerpt, excerptHtml
Blog title
Page title, body
Product title, descriptionHtml, description
ProductOption name, values
ProductVariant title, selectedOptions
ShopPolicy body

Retrieve a resource's ID

You need a resource's ID to retrieve its translations. The following example retrieves the ID of a product with the title white t-shirt:

POST /api/2021-07/graphql.json

JSON response

Retrieve Storefront API translations

To query translatable resources and return translated content, include the Accept-Language HTTP header in your request.

The following example returns the Spanish translations for a product's title, description, and options.

Header

Accept-Language: es

Variables

You can specify an array of resource IDs that you want to retrieve translations for.

Query: POST /api/2021-07/graphql.json

JSON response

Next steps

  • Learn how to query international prices for products and orders, and explicitly set the context of a cart and checkout.
  • Learn how to manage a cart in Shopify with the Storefront API.
  • Retrieve metafields with the Storefront API to access additional information from different types of resources.
  • Learn how to manage customer accounts with the Storefront API.
  • Learn about the different tools that you can use to create unique buying experiences anywhere your customers are, including websites, apps, and video games.