Back to Content Management API
locale
Returns one of your store's locales by ID, or null if it doesn't exist. A locale's id is the localeId the *Translate mutations take. See Localization.
Arguments
- Name
id- Type
- ID!
- Description
The ID of the locale.
Returns
- Name
Locale.*- Type
- Locale
- Description
Any requested field from the Locale object.
Request
import { PackClient } from '@pack/client'
const packClient = new PackClient({
token: 'YOUR-PACK-TOKEN'
});
const query = `
query Locale($id: ID!) {
locale(id: $id) {
id
languageCode
countryCode
isPrimary
active
fallbackLocale {
id
languageCode
countryCode
}
}
}
`;
const variables = {
id: 'YOUR-LOCALE-ID'
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);
Response
{
"data": {
"locale": {
"id": "YOUR-LOCALE-ID",
"languageCode": "fr",
"countryCode": "CA",
"isPrimary": false,
"active": true,
"fallbackLocale": {
"id": "YOUR-FALLBACK-LOCALE-ID",
"languageCode": "fr",
"countryCode": "FR"
}
}
}
}