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 .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
// Creates an instance of the delivery client
// ProTip: Use DI for this in your apps https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
.WithProjectId("8d20758c-d74c-4f59-ae04-ee928c0816b7")
.Build();
// Gets an article in Spanish
// Create strongly typed models according to https://kontent.ai/learn/net-strong-types
IDeliveryItemResponse<Article> response = await client.GetItemAsync<Article>("about_us",
new LanguageParameter("es-ES")
);
Article item = response.Item;
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
// Creates an instance of the delivery client
// ProTip: Use DI for this in your apps https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
.WithProjectId("8d20758c-d74c-4f59-ae04-ee928c0816b7")
.Build();
// Gets the 'About us' content item in Spanish based on the item's URL slug value
// Create strongly typed models according to https://kontent.ai/learn/net-strong-types
IDeliveryItemListingResponse<Article> response = await client.GetItemsAsync<Article>(
new LanguageParameter("es-ES"),
new EqualsFilter("system.type", "article"),
new EqualsFilter("elements.url_pattern", "acerda-de-nosotros")
);
IList<Article> items = response.Items;
// Tip: Find more about .NET SDKs at https://kontent.ai/learn/net
using Kontent.Ai.Delivery;
// Creates an instance of the delivery client
// ProTip: Use DI for this in your apps https://kontent.ai/learn/net-register-client
IDeliveryClient client = DeliveryClientBuilder
.WithProjectId("975bf280-fd91-488c-994c-2f04416e5ee3")
.Build();
// Gets the Spanish variant of all content items and ignores language fallbacks
IDeliveryItemListingResponse<object> response = await
client.GetItemsAsync<object>(
new LanguageParameter("es-ES"),
new EqualsFilter("system.language", "es-ES")
);
IList<object> items = response.Items;