Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 34c679f

Browse files
Ivan KiralIvan Kiral
authored andcommitted
Update readme with language fallbacks
1 parent ace344d commit 34c679f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,20 @@ You might want to request items based on the URL slugs. For more information che
231231
232232
> The showcase is not ideal, because it is using a combination of the language prefix and localizable solution is not ideal. You should try to stick with one of the approaches. Because it is hard to define the behavior for language setting clash i.e. `/<EN-PREFIX>/articles/<ES-URL-SLUG>`.
233233
234+
### Language fallbacks
235+
236+
To deal with content that is not available in current language, this project uses method called language fallbacks. It will fetch the content in the language which set as fallback language in the Kontent.ai project and redirect the website to the URL with prefix of the given language. However, it is possible to disable language fallbacks by adding a filter of `system.language` to your query. For more information about getting localized content check this [`link.`](https://kontent.ai/learn/tutorials/develop-apps/get-content/localized-content-items/?tech=javascript)
237+
238+
```js
239+
var query = Client.items<AboutUs>().type(contentTypes.about_us.codename);
240+
241+
if (this.language) {
242+
query
243+
.languageParameter(this.language)
244+
.equalsFilter('system.language', 'es-ES');
245+
}
246+
```
247+
234248
## Handling 404
235249
236250
For the not found resources, prefixed 404 pages are used for both languages. As the content on one page should be in one language, this approach might help you to optimize SEO. If language is not set in the URL the application uses the last used language, which is set in cookies.

0 commit comments

Comments
 (0)