Settings
Locales configuration

Locales Configuration

This overview explains how to manage locales using the GraphQL Admin API.

Introduction

The BigCommerce GraphQL Admin API enables developers to manage languages across different channels. By accessing locale data and related configurations, developers can more easily localize headless storefronts.

Locale management is available on Catalyst storefronts.

Getting started

With the GraphQL Admin API, merchants can add, update, or remove locales for each sales channel, change locale status, and set a locale as the default. Below are examples of GraphQL queries and mutations for retrieving and managing locale settings.

Example requests

This section provides examples of GraphQL Admin API queries and mutations that demonstrate how to manage locales, along with the required HTTP configuration.

GraphQL Admin API HTTP configuration
POST https://api.bigcommerce.com/accounts/{{store_hash}}/graphql
X-Auth-Token: {{access_token}}
Accept: application/json
Content-Type: application/json

Query locales supported by the platform

This query returns a static list of all locales currently supported by the platform.

Example query: Get locales supported by the platform
query {
  i18n {
    supportedLocales {
      code
      englishName
      hasBuiltInTranslations
      }
    }
  }

Query channel locales

The following query returns channel locales.

Example query: Get locales
query {
  store {
    locales(input: { channelId: "bc/store/channel/1"}) {
      edges {
        node {
          code
          status
          isDefault
        }
      }
    }
  }
}

Add a locale

The following mutation adds a locale.

Example query: Add a locale
mutation {
  locale {
     addLocale(input: {
        channelId: "bc/store/channel/1",
        code: "fr",
        status: INACTIVE
        }) {
              locale {
                  code
                  status
            }
              errors {
                  ... on Error {
                  message
                        }
                    }
                }
            }
        }

Update a locale

The following mutation updates a channel's locale.

Example query: Update a locale
  mutation {
   locale {
      updateLocale(input: {
         channelId: "bc/store/channel/1",
         code: "fr",
         status: ACTIVE,
         isDefault: false
         }) {
               locale {
                   code
                   status
                   isDefault
             }
               errors {
                   ... on Error {
                       message
                         }
                     }
                 }
             }
         }

Delete a locale

The following mutation deletes a channel's locale.

Example query: Delete a locale
 mutation {
   locale {
      deleteLocale(input: {
         channelId: "bc/store/channel/1",
         code: "fr",
         }) {
               code
               errors {
                   ... on Error {
                   message
                         }
                     }
                 }
             }
         }
Did you find what you were looking for?