Locale

Locale

Source:
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.

Methods

(static) update() → {Promise.<Locale.Locale>}

Source:
The Update Locale call lets you update the name and description of an existing Locale.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack({ api_key: 'api_key'}).locale('locale_code').fetch()
.then((locale) => {
 locale.title = 'My New Content Type'
 locale.description = 'Content Type description'
 return locale.update()
})
.then((locale) => console.log(locale))
Returns:
Promise for Locale instance
Type
Promise.<Locale.Locale>

(static) delete() → {Object}

Source:
The Delete Locale call is used to delete an existing Locale permanently from your Stack.
Example
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))
Returns:
Response Object.
Type
Object

(static) fetch(version) → {Promise.<Locale.Locale>}

Source:
The fetch Locale call fetches Locale details.
Example
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))
Parameters:
Name Type Description
version Int Enter the unique ID of the content type of which you want to retrieve the details. The UID is generated based on the title of the content type. The unique ID of a content type is unique across a stack.
Returns:
Promise for Locale instance
Type
Promise.<Locale.Locale>

(static) create() → {Promise.<Locale.Locale>}

Source:
The Create a content type call creates a new content type in a particular stack of your Contentstack account.
Example
import * as contentstack from '@contentstack/management'
const client = contentstack.client()

client.stack().locale().create({ locale: { code: 'en-at' } )
.then((locale) => console.log(locale))
Returns:
Promise for Locale instance
Type
Promise.<Locale.Locale>

(static) query(include_count) → {Array.<Locale>}

Source:
The Query on Content Type will allow to fetch details of all or specific Content Type
Example
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))
Parameters:
Name Type Description
include_count Boolean Set this to 'true' to include in response the total count of content types available in your stack.
Returns:
Array of ContentTyoe.
Type
Array.<Locale>