Locales
A locale is a culture code that consists of a two-letter language code and a two-letter region code, for example, the locale for American English is en-US and for British English is en-GB. To create a localized copy of a content item, an Administrator must have already defined the locales. You can add, edit, or delete a locale using either the API or the Content Hub ONE app if you have the necessary permissions. And, when required, you can retrieve or update the default locale.
Get all locales
Use this method to retrieve a list of locales. If you don't specify any filtering parameters, you will retrieve all available locales.
curl --location --request GET '<BASE_URL>/api/content/v1/locales' \
--header 'Accept: text/plain' \
--header 'Authorization: <BEARER_TOKEN>'
{
"totalCount": 6,
"data": [
{
"id": "es-GT",
"name": "Spanish (Guatemala)"
},
{
"id": "nl-BE",
"name": "Dutch (Belgium)"
},
{
"id": "fr-CA",
"name": "French (Canada)"
},
{
"id": "en-US",
"name": "English (United States)"
},
{
"id": "sv-SE",
"name": "Swedish (Sweden)"
},
{
"id": "es-ES",
"name": "Spanish (Spain)"
}
]
}Get a locale using the ID
Use this method to retrieve a locale with a specific ID. For a list of all available IDs, run the GET api/content/v1/locales method. To view a specific locale ID, open the relevant locales details page. This request returns a locale with the ID sv-SE.
curl --location --request GET '<BASE_URL>/api/content/v1/locales/sv-SE' \
--header 'Authorization: <BEARER_TOKEN>'
{
"id": "sv-SE",
"name": "Swedish (Sweden)"
}Create a locale
Use this method to create a locale. This request creates a locale called es-CL for Spanish (Chile) and sets it as the default locale.
curl --location --request POST '<BASE_URL>/api/content/v1/locale' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
"id": "es-CL",
"name": "Spanish (Chile)",
"default": true
}'
{
"id": "es-CL",
"name": "Spanish (Chile)",
"default": true
}Update a locale
Use this method to update a locale. In this example, the name of the locale is being changed from French (France) to French (fr-FR) and the locale is no longer the default.
curl --location --request PUT '<BASE_URL>/api/content/v1/locales/fr-FR' \
--header 'Content-Type: application/json' \
--header 'Authorization: <BEARER_TOKEN>' \
--data '{
"name": "French (fr-FR)",
"default":false
}'
{
"id": "fr-FR",
"name": "French (fr-FR)"
}Delete a locale
Use this method to delete a locale with a specific ID. You cannot delete a locale if it is being used by a content item or if it is the default locale. This request deletes a locale with the ID nl-NL.
curl --location --request DELETE '<BASE_URL>/api/content/v1/locales/nl-NL' \
--header 'Authorization: <BEARER_TOKEN>'
Get supported locales
Use this method to retrieve a list of supported locales. If you don't specify any filtering parameters, you will retrieve all supported locales.
curl --location --request GET '<BASE_URL>/api/content/v1/locales/supported' \
--header 'Accept: text/plain' \
--header 'Authorization: <BEARER_TOKEN>'