Sorry, we don't support your browser.  Install a modern browser

I18n - Fallback languages#35

It’d be great to be able to configure the API to automatically fallback from locale 1 to locale 2 when no value for locale 1 is found.

For instance, my website’s goal is to display content. I want to display something, even when the content hasn’t been translated yet in the user’s primary language. In such case, I’d like to decide a fallback language (or several, in order), based on the user’s primary language.

This would allow to display my content in chinese, and fallback to english when a specific field hasn’t been translated.

A very good example and doc is available at https://www.i18next.com/principles/fallback#fallback-language

Right now, it’s possible manually from the client consumming the GraphCMS API. But it requires for all fields to fetch multiple locales in order to fallback to them in case some fiels aren’t translated. It’s both cumbersome, error prone, takes time and increases bandwith.

When implementing such system on the GraphCMS API level, I strongly suggest you anticipate several “scenarios”, because not everybody may want such behaviour, it should be opt-in, and other way to “fallback” may arise, based on your customers needs.

a year ago

We already have that in place and will also add it to our documentation soon!
We introduced two new headers: gcms-locale & gcms-locale-no-default. The first one takes a comma separated list of locales and the second one is a boolean flag that enables or disables the fallback to the default if all of the specified headers in gcms-locale are null.

a year ago
1

@Ambroise Dhenain ping on this since I will be closing it!

a year ago
Changed the status to
Completed
a year ago