Skip to content

Commit

Permalink
DEVDOCS-6167: [new] GraphQL Admin channel locales (#747)
Browse files Browse the repository at this point in the history
<!-- Ticket number or summary of work -->
# [DEVDOCS-6167]


## What changed?
Add new article for Locales per Channel using Admin GraphQL

## Release notes draft
<!-- Provide an entry for the release notes using simple, conversational
language. Don't be too technical. Explain how the change will benefit
the merchant and link to the feature.

Examples:
* The newly-released [X feature] is now available to use. Now, you’ll be
able to [perform Y action].
* We're happy to announce [X feature], which can help you [perform Y
action].
* [X feature] helps you to create [Y response] using the [Z query
parameter]. Now, you can deliver [ex, localized shopping experiences for
your customers].
* Fixed a bug in the [X endpoint]. Now the [Y field] will appear when
you click [Z option]. -->
* 

## Anything else?
<!-- Add related PRs, salient notes, additional ticket numbers, etc. -->

ping {names}


[DEVDOCS-6167]:
https://bigcommercecloud.atlassian.net/browse/DEVDOCS-6167?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

---------

Co-authored-by: bc-andreadao <[email protected]>
  • Loading branch information
bc-traciporter and bc-andreadao authored Jan 15, 2025
1 parent 957328b commit abf98cc
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/integrations/webhooks/events/channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,9 @@ The following settings webhook events fire in response to actions that affect a
| `store/channel/{channel_id}/settings/*` | Fires when subscribed to all settings updates for the specified channel. | not applicable |
| `store/channel/{channel_id}/settings/currency/updated` | Fires when currency associated with the specified channel is updated. | not applicable |
| `store/channel/{channel_id}/settings/profile/updated` | Fires when any of the global store profile settings are updated. Fires for both channel-specific profile settings changes and for changes to any global defaults that the specified channel inherits. | [Update store profile settings](/docs/rest-management/settings/store-profile#update-store-profile-settings) |
| `store/channel/{channel_id}/settings/locale/added` | Fires when a locale is added to any channel.| [Add a locale](/docs/store-operations/settings/locales#add-a-locale) |
| `store/channel/{channel_id}/settings/locale/updated` | Fires when a locale is updated for any channel. | [Update a locale](/docs/store-operations/settings/locales#update-a-locale) |
| `store/channel/{channel_id}/settings/locale/deleted` | Fires when a locale is deleted from any channel.| [Delete a locale](/docs/store-operations/settings/locales#delete-a-locale) |
| `store/channel/{channel_id}/settings/logo/updated` | Fires when any of the global logo settings are updated.| [Update store logo settings](/docs/rest-management/settings/logo#update-store-logo-settings) |
| `store/channel/{channel_id}/settings/logo/image/updated` | Fires when any of the logo image settings that apply to the specified channel are updated.| not applicable |
| `store/channel/{channel_id}/settings/favicon/image/updated` | Fires when any of the favicon image settings that apply to the specified channel are updated.| not applicable |
Expand Down
2 changes: 1 addition & 1 deletion docs/store-operations/settings/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Managing Store Configuration
# Store Configuration

[Settings API reference documentation](/docs/rest-management/settings)

Expand Down
260 changes: 260 additions & 0 deletions docs/store-operations/settings/locales.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
# Locales Configuration

This overview explains how to manage locales using the [GraphQL Admin API](/docs/graphql-admin).

## 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.

<Callout type="info">
Locale management is available on Catalyst storefronts.
</Callout>

## 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.

```http filename="GraphQL Admin API HTTP configuration" showLineNumbers copy
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.
<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example query: Get locales supported by the platform" showLineNumbers copy
query {
i18n {
supportedLocales {
code
englishName
hasBuiltInTranslations
}
}
}
```
</Tab>
<Tab>
```json filename="Example query: Get locales supported by the platform" showLineNumbers copy
{
"data": {
"i18n": {
"supportedLocales": [
{
"code": "ua",
"englishName": "Ukrainian",
"hasBuiltInTranslations": "false"
},
{
"code": "en-US",
"englishName": "English (United States)",
"hasBuiltInTranslations": "true"
},
{
"code": "en-UK",
"englishName": "English (United Kingdom)",
"hasBuiltInTranslations": "true"
},
{
"code": "fr",
"englishName": "French",
"hasBuiltInTranslations": "true"
}
}
}
}
```
</Tab>
</Tabs>

### Query channel locales

The following query returns channel locales.

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example query: Get locales" showLineNumbers copy
query {
store {
locales(input: { channelId: "bc/store/channel/1"}) {
edges {
node {
code
status
isDefault
}
}
}
}
}
```
</Tab>
<Tab>

```json filename="Example query: Get locales" showLineNumbers copy
{
"data": {
"store": {
"locales":
"edges": [
{
"node": {
"code": "en",
"status": "INACTIVE",
"isDefault": true
}
}
]
}
}
}
```
</Tab>
</Tabs>

### Add a locale

The following mutation adds a locale.

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example query: Add a locale" showLineNumbers copy
mutation {
locale {
addLocale(input: {
channelId: "bc/store/channel/1",
code: "fr",
status: INACTIVE
}) {
locale {
code
status
}
errors {
... on Error {
message
}
}
}
}
}
```
</Tab>
<Tab>
```json filename="Example query: Add a locale" showLineNumbers copy
{
"data": {
"locales": {
"addlocale":
"locale": {
"code": "fr",
"status": "INACTIVE",
"isDefault": false
},
"errors": []
}
}
}
}
```
</Tab>
</Tabs>

### Update a locale

The following mutation updates a channel's locale.

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example query: Update a locale" showLineNumbers copy
mutation {
locale {
updateLocale(input: {
channelId: "bc/store/channel/1",
code: "fr",
status: ACTIVE,
isDefault: false
}) {
locale {
code
status
isDefault
}
errors {
... on Error {
message
}
}
}
}
}
```
</Tab>
<Tab>
```json filename="Example query: Update a locale" showLineNumbers copy
{
"data": {
"locale": {
"updateLocale": {
"locale": {
"code": "fr",
"status": "ACTIVE",
"isDefault": false
},
"errors": []
}
}
}
}
```
</Tab>
</Tabs>

### Delete a locale

The following mutation deletes a channel's locale.

<Tabs items={['Request', 'Response']}>
<Tab>
```graphql filename="Example query: Delete a locale" showLineNumbers copy
mutation {
locale {
deleteLocale(input: {
channelId: "bc/store/channel/1",
code: "fr",
}) {
code
errors {
... on Error {
message
}
}
}
}
}
```
</Tab>
<Tab>
```json filename="Example query: Delete a locale" showLineNumbers copy
{
"data": {
"locale": {
"deleteLocale": {
"code": "fr",
"errors": []
}
}
}
}
```
</Tab>
</Tabs>


0 comments on commit abf98cc

Please sign in to comment.