Locale

View as Markdown

Locale

Contentstack has a sophisticated multilingual capability. It allows you to create and publish entries in any language. This feature allows you to set up multilingual websites and cater to a wide variety of audience by serving content in their local language(s). Read more about Locales.

update

The Update Locale call lets you update the name and description of an existing Locale.

NameTypeDescription
bodyJSONObject

The request body

import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).locale('locale_code').fetch()
.then((locale) => {
  locale.fallback_locale = 'en-at'
  return locale.update()
})
.then((locale) => console.log(locale))

delete

The Delete Locale call is used to delete an existing Locale permanently from your Stack.

import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).locale('locale_code').delete()
.then((response) => console.log(response.notice))

fetch

The fetch Locale call fetches Locale details.

NameTypeDescription
versionInt

UID of the content type of which you want to retrieve the details

import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).locale('locale_code').fetch()
.then((locale) => console.log(locale))

create

The Create a content type call creates a new content type in a particular stack of your Contentstack account.

NameTypeDescription
bodyJSONObject

The request body

import * as contentstack from '@contentstack/management'

const client = contentstack.client()


client.stack({ api_key: 'api_key'}).locale().create({ locale: { code: 'en-at' } )

.then((locale) => console.log(locale))

query

The Query on Locale will allow to fetch details of all or specific Locale

 

NameTypeDescription
include_countBoolean

Total count of content types available in your stack.

limitnumber

Specifies the maximum number of items to return.

Default: 100
skipnumber

Specifies the number of items to skip from the returned results. Useful for pagination.

Default: 100
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack(api_key).locale().query({ query: { code: 'locale-code' } }).find()
.then((locales) => console.log(locales))

Note Always include the locale filter inside the query object when filtering entries.

  • Correct usage query({ query: { locale: 'en-gb' } })
    Returns only entries that match the specified locale.
  • Incorrect usage query({ locale: 'en-gb' })
    The locale is treated as a query option, not a filter. All entries are returned.