If you plan to display culture-specific content, your app needs to know how to retrieve content in specific languages.Depending on what you know about your content, there are a few ways to go about this.
Languages and localization
Each language in your Kontent.ai project is uniquely identified by its codename. The codename can be any string, such as English, en-US, or en-GB.
Get content in a specific language
To get localized content from your project, specify the language using the language's codename. For example, to get an article named About Us in Spanish, specify the item's codename and the language's codename.
Get items by localized URL slug
Depending on how you implement routing in your app, you might want to request content items by their URL slugs.If all you know about the content item is its URL slug, you need to request all items and filter them by the URL slug. This approach scales for both small and enterprise projects.To retrieve a localized content item by its URL slug, you need to do two things when making the API call:
Specify the language using the language’s codename, such as es-ES for Spanish.
Filter by the URL slug element’s value.
If the specified query doesn’t match any content items, the Delivery API returns an empty response.
Ignoring language fallbacks
If you need to ensure you get content in only the specified language, you can filter out the content items that are in another language than specified. This effectively bypasses any language fallbacks.For example, this is how you retrieve content items translated into Spanish without any fallbacks.
The following table shows what content the API returns for specific combinations of language-related filters. The example assumes a project with the default language set as English 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
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.
The API returns only content items in Spanish. If an item is not translated to Spanish, the API doesn't return it.
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.
Filter content to get what you need
The Delivery API provides several filters to help you refine your requests based on your requirements. To choose the right one, think about what you know about the content you want to get. There’s a filter for every use case.Find a scenario relevant to you and adjust the code samples to get the content you need.
Your default languageEvery project comes with a single default language that cannot be removed. When you request content without specifying a language, Delivery API returns content in the default language.
What if the item doesn't exist in the specified language?The Delivery API checks the fallbacks of the specified language. If the content exists in the fallback language set for the requested language, you get the content item's content in the fallback language.