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.

This feature is currently available for Catalyst channels. We are actively working to extend locale management capabilities to other channel types in upcoming releases.

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.

Each storefront can have up to 5 locales.

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/stores/{{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
1query {
2 i18n {
3 supportedLocales {
4 edges {
5 node {
6 code
7 englishName
8 hasBuiltInTranslations
9 }
10 }
11 }
12 }
13 }

Query channel locales

The following query returns channel locales.

Example query: Get locales
1query {
2 store {
3 locales(input: { channelId: "bc/store/channel/1"}) {
4 edges {
5 node {
6 code
7 status
8 isDefault
9 }
10 }
11 }
12 }
13}

Add a locale

The following mutation adds a locale.

Example query: Add a locale
1mutation {
2 locale {
3 addLocale(input: {
4 channelId: "bc/store/channel/1",
5 code: "fr",
6 status: INACTIVE
7 }) {
8 locale {
9 code
10 status
11 }
12 errors {
13 ... on Error {
14 message
15 }
16 }
17 }
18 }
19 }

Update a locale

The following mutation updates a channel’s locale.

Example query: Update a locale
1 mutation {
2 locale {
3 updateLocale(input: {
4 channelId: "bc/store/channel/1",
5 code: "fr",
6 status: ACTIVE,
7 isDefault: false
8 }) {
9 locale {
10 code
11 status
12 isDefault
13 }
14 errors {
15 ... on Error {
16 message
17 }
18 }
19 }
20 }
21 }

Delete a locale

The following mutation deletes a channel’s locale.

Example query: Delete a locale
1 mutation {
2 locale {
3 deleteLocale(input: {
4 channelId: "bc/store/channel/1",
5 code: "fr",
6 }) {
7 code
8 errors {
9 ... on Error {
10 message
11 }
12 }
13 }
14 }
15 }