Ways to get localized content
Is this page helpful?
English
, en-US
, or en-GB
.
es-ES
for Spanish.en-US
and the second language set as Spanish es-ES
, which falls back to the default language.
language=es-ES
– Specifies the codename of the requested language.system.language=es-ES
– Filters content items by their language.language parameter value | system.language parameter value | Behavior |
es-ES | <not set> | The API returns content items in Spanish. If an item is not translated to Spanish, the API returns the English (en-us ) version of the items as fallback. |
es-ES | es-ES | The API returns only content items in Spanish. If an item is not translated to Spanish, the API doesn't return it. |
es-ES | en-US | The API returns only content items in English provided they don't have content in Spanish. If an item is translated to Spanish, it is not returned. |
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
import kontent.ai.delivery.*;
// Initializes a DeliveryClient
DeliveryClient client = new DeliveryClient("<YOUR_PROJECT_ID>");
// Create strongly typed models according to https://kontent.ai/learn/strongly-typed-models
// Registers the model class for articles
client.registerType(Article.class);
// Gets the Spanish variant of an article
CompletionStage<Article> item = client.getItem(
"about_us",
Article.class,
DeliveryParameterBuilder.params()
.language("es-ES")
.build()
);
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
import kontent.ai.delivery.*;
// Initializes a DeliveryClient
DeliveryClient client = new DeliveryClient("<YOUR_PROJECT_ID>");
// Create strongly typed models according to https://kontent.ai/learn/strongly-typed-models
// Registers the model class for articles
client.registerType(Article.class);
// Gets the Spanish variant of an "About us" content item that has "acerda-de-nosotros" in its "URL pattern" element
CompletionStage<List<Article>> items = client.getItems(
Article.class,
DeliveryParameterBuilder.params()
.language("es-ES")
.filterEquals("system.type", "article")
.filterEquals("elements.url_pattern", "acerda-de-nosotros")
.build();
);
// Tip: Find more about Java SDK at https://kontent.ai/learn/java
import kontent.ai.delivery.*;
// Initializes a DeliveryClient
DeliveryClient client = new DeliveryClient("<YOUR_PROJECT_ID>");
// Gets the Spanish variant of all content items (while ignoring language fallbacks)
CompletionsStage<ContentItemsListingResponse> listingResponse = client.getItems(
DeliveryParameterBuilder.params()
.language("es-ES")
.filterEquals("system.language", "es-ES")
.build()
);