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 audiences by serving content in their local language(s).

update

The "Update language" call will let you update the details (such as display name) and the fallback language of an existing language of your stack.

When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.

NameTypeDescription
body (required)JSONObject

Thee body should be a JSON Object.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.update(body).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

delete

The "Delete language" call deletes an existing language from your stack.

When executing the API call, under the 'Header' section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.delete().execute();

if(response.isSuccessful) {

    System.out.println("Response" + response);

}

find

This call fetches the list of all languages (along with the language codes) available for a stack.

When executing the API call, under the Header section, you need to enter the authtoken that you receive after logging into your account.

You can add queries to extend the functionality of this API call. Under the URI Parameters section, insert a parameter named query and provide a query in JSON format as the value.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.find().execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

removeParam

Set header for the request.

NameTypeDescription
key (required)String

Removes query parameters using the key of the request.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale=contentstack.stack().locale();

locale.removeParam("key");

addHeader

Sets header for the request.

NameTypeDescription
key (required)String
Header key for the request.
value (required)Object
Header value for the request.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale ocale = contentstack.stack().locale();

locale.addHeader("key", value);

setFallback

The "Set a fallback" language request allows you to assign a fallback language for an entry in a particular language.

When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging in to your account.

NameTypeDescription
body (required)JSONObject

The request body.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.setFallback(body).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

updateFallback

The "Update fallback language" request allows you to update the fallback language for an existing language of your stack.

When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging in to your account.

NameTypeDescription
body (required)JSONObject

The request body.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.updateFallback(body).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

fetch

The "Get a language" call returns information about a specific language available on the stack.

When executing the API call, under the 'Header' section, you need to enter the authtoken that you receive after logging into your account.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.fetch().execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

create

This call lets you add a new language to your stack. You can either add a supported language or a custom language of your choice.

When executing the API call, under the Header section, you need to enter the API key of your stack and the authtoken that you receive after logging into your account.

NameTypeDescription
body (required)JSONObject

The request body.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

Call<ResponseBody> response = locale.create(body).execute();

if (response.isSuccessful) {

    System.out.println("Response" + response);

}

addParam

Sets header for the request.
NameTypeDescription
key (required)String
Query parameter key for the request.
value (required)Object
Query parameter value for the request.

import contentstack;

Contentstack contentstack = new Contentstack.Builder().build();

Locale locale = contentstack.stack().locale();

response = locale.addParam("key", value);