Locale
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 audiences by serving content in their local language(s).
find
The find method retrieves the list of all languages (along with the language codes) available for a stack.
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack("api_key").locale().find().json()fetch
The fetch method retrieves information about a specific language available on the stack.
| Name | Type | Description |
|---|---|---|
| locale_code (required) | str | Code of the specific language |
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').locale('locale_code').fetch().json()create
The create method lets you add a new language to your stack. You can either add a supported language or a custom language of your choice.
| Name | Type | Description |
|---|---|---|
| data (required) | Dict | Data required to create a new locale |
data = {
"locale":{
"name":"Arabic - Bahrain",
"code":"ar-bh",
"fallback_locale":"en-us"
}
}
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale().create(data).json()update
The update method lets you update the details (such as display name) and the fallback language of an existing language of your stack.
| Name | Type | Description |
|---|---|---|
| data (required) | Dict | The updated data of the locale |
| locale_code (required) | str | Code of the specific language |
data ={
"locale":{
"name":"Updated Locale Name",
"fallback_locale":"zh-cn"
}
}
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale("locale_code").update(data).json()Delete
The delete method removes an existing language from your stack.
| Name | Type | Description |
|---|---|---|
| locale_code (required) | str | Code of the specific language |
import contentstack_management
client = contentstack_management.Client(authtoken='authtoken')
response = client.stack('api_key').locale(locale_code).delete().json()Set_fallback
The Set_fallback method allows you to assign a fallback language for an entry in a particular language.
| Name | Type | Description |
|---|---|---|
| data (required) | Dict | Data required to assign the fallback language |
data = {
"locale":{
"name":"Arabic - Bahrain",
"code":"ar-bh",
"fallback_locale":"en-us"
}
}
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale().set_fallback(data).json()Update_fallback
The Update_fallback method allows you to update the fallback language for an existing language of your stack.
| Name | Type | Description |
|---|---|---|
| data (required) | Dict | Data required to assign the fallback language |
| locale_code (required) | str | Code of the specific language |
data = {
"locale": {
"name": "German",
"code": "de",
"fallback_locale": "en-us"
}
}
import contentstack_management
client = contentstack_management.Client(authtoken='your_authtoken')
response = client.stack('api_key').locale("locale_code").update_fallback(data).json()