Anchor to section titled 'undefined'

shopLocaleEnable
mutation

Requires write_locales access scope.

Adds a locale for a shop. The newly added locale is in the unpublished state.


ISO code of the locale to enable.

The list of markets web presences to add the locale to.


Was this section helpful?

ISO code of the locale that was enabled.

The list of errors that occurred from executing the mutation.


Was this section helpful?

Examples

Hide code
DescriptionCopy
mutation enableLocale($locale: String!) {
  shopLocaleEnable(locale: $locale) {
    userErrors {
      message
      field
    }
    shopLocale {
      locale
      name
      primary
      published
    }
  }
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation enableLocale($locale: String!) { shopLocaleEnable(locale: $locale) { userErrors { message field } shopLocale { locale name primary published } } }",
 "variables": {
    "locale": "ko"
  }
}'
const { admin } = await authenticate.admin(request);

const response = await admin.graphql(
  `#graphql
  mutation enableLocale($locale: String!) {
    shopLocaleEnable(locale: $locale) {
      userErrors {
        message
        field
      }
      shopLocale {
        locale
        name
        primary
        published
      }
    }
  }`,
  {
    variables: {
      "locale": "ko"
    },
  },
);

const data = await response.json();
session = ShopifyAPI::Auth::Session.new(
  shop: "your-development-store.myshopify.com",
  access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
  session: session
)

query = <<~QUERY
  mutation enableLocale($locale: String!) {
    shopLocaleEnable(locale: $locale) {
      userErrors {
        message
        field
      }
      shopLocale {
        locale
        name
        primary
        published
      }
    }
  }
QUERY

variables = {
  "locale": "ko"
}

response = client.query(query: query, variables: variables)
const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation enableLocale($locale: String!) {
      shopLocaleEnable(locale: $locale) {
        userErrors {
          message
          field
        }
        shopLocale {
          locale
          name
          primary
          published
        }
      }
    }`,
    "variables": {
      "locale": "ko"
    },
  },
});
use Shopify\Clients\Graphql;

$client = new Graphql("your-development-store.myshopify.com", $accessToken);
$query = <<<QUERY
  mutation enableLocale($locale: String!) {
    shopLocaleEnable(locale: $locale) {
      userErrors {
        message
        field
      }
      shopLocale {
        locale
        name
        primary
        published
      }
    }
  }
QUERY;

$variables = [
  "locale" => "ko",
];

$response = $client->query(["query" => $query, "variables" => $variables]);
Hide code
Input variables
Copy
{
  "locale": "ko"
}
Hide code
Response
JSON
{
  "shopLocaleEnable": {
    "userErrors": [],
    "shopLocale": {
      "locale": "ko",
      "name": "Korean",
      "primary": false,
      "published": false
    }
  }
}