-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback locale in case formatMessage failure #58
Comments
There isn't currently a locale-based fallback mechanism for That said, there are a couple of workarounds that may or may not help:
|
Thanks for your response
Definitely. I used English as an example, but in practice the fallback locale would probably be decided from a prop.
Yeah, this is basically the workaround that I opted for. It has a bit more steps than my example, but essentially: loadMessages({
de: {
...englishMessages,
...germanMessages,
},
}); For now I'm happy with this solution, as it seems to cover my needs entirely 👍 |
Sounds good, that does seem like a decent workaround for now. Per another issue that came up earlier today, a |
Hey, thanks for a great library!
Currently I'm in the process of converting our ancient, manual i18n logic to something more streamlined, and I think this library seems like a great fit!
I was wondering though, if it would be possible to set a default locale that would be fallen back to in case
formatMessage
fails when a local key is missing. In our project, we sometimes make releases before all our translators have translated each new key. In this case we want to fall back to English.For example, let's say we add a new message, and neglect to translate it to German. If we call
formatMessage
for that key in DE locale, we don't have a German translation. In this case, I'd like to fall back to English. Only if English key wouldn't exist either, should we fall back to rendering the key itself. Is this possible? I didn't find support for this behavior in your documentation.The text was updated successfully, but these errors were encountered: