-
-
Notifications
You must be signed in to change notification settings - Fork 861
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
Feature Request: Fallback Locale as array for cascading fallbacks. #138
Comments
Other i18n packages offer "ultimate" fall backs directly with the text such as : <span>{{ $t('label.signup', 'Sign Up') }}</span> Does vue-i18n have no such capability? I don't see how to do it, but I certainly believe it's necessary. |
@martinhbramwell Sometimes I use the string as the key, which could be useful for you if you need a "ultimate" fallback: <span>{{ $t('Sign Up') }}</span> And then, set up your fallback to (Spanish in this example): const i18n = new VueI18n({
locale: 'es-VE',
fallbackLocale: 'es',
messages: { }
}) But, would be useful if the @nchutchind suggestion is implemented. 💯 |
This feature seems trivial when handling locale, I guess @kazupon originally intended this project to support only languages. @nchutchind , did you perhaps manage to solve this yourself somehow? |
@drorweissweiss No, I did not put much more effort into it. I just noticed that it wasn't supported and figured I'd bring it up. |
In my opinion, fallbacks are obligatory for any package that wants to use I18N in its name. I appreciate the point @nelson6e65 makes, but @nchutchind is right in his original request, that easy automatic fall back from dialect, to major language, to English is essential. |
Yes. I think auto-fallback are necessary, @martinhbramwell. If |
What's the status of this idea? It would be very useful. Especially if we have per-language translation strings and want to add per-locale date formatting. |
I also think that fallback handling must be improved. As described here: https://www.i18next.com/principles/fallback, let me reexplain what should be done. For the vocabulary, let me remind you that a "locale" like "fr-ca" is composed of the language ("fr") and the territory ("ca"). First of all, the developer should provide defaut messages for a language, then potentially variations for a territory. Then here is what should happen: Simple use cases - keep working with a stringIf
Then
More complex use cases - provide an objectThe above should suffice for most people but more must be done to accomodate other use cases. Let's say that: If
Then, just as explained above:
However, if I want
...that is not possible with So here is the object I would need to be able to pass to achieve it:
Remarks:
The order of checks for someone who comes with
Going fully manual - provide an arrayIf I wanted to easily use some custom pattern for example based on the user preferences (rather than a config file), I should be able to provide an array rather than an object:
But honestly I dont' think this third stage is a priority. It allows every kind of scenarios but it lets the developper do all the work of computing the fallbacks. And it can be achieved with an object too, although less simple to elaborate. |
Thanks @louisameline It would be happy if I think |
@exoego I thought some more about this and amended my previous message with a more definitive wrap-up of the subject. As you'll see, there are actually 3 layers of improvement that don't need to be done at the same time. It would actually be fun to code, but I don't know when I'll have time for this, so I'm not making any promises. Thank you very much |
I think this should be implicit, instead of explicit. I mean... you should only need one fallback. If you set your locale to I would like enjoy learning how can I help to this issue, but... I have not time right now. 😭 |
@nelson6e65 Yes that's what I have in mind too. I reformulated the sentence in case it wasn't clear enough. |
I would really love to see this feature soon. |
* - adds tests for fallbacks to be implemented (#2) * adds tests for fallbacks to be implemented (#2) * implementation for complex fallback variants (#2) * fixed test errors (#2) * fixed some documentation (#2) * fixes fallback test (#2) * refactor fallback tests (#2) * allow fallbackLocale to be false explicit (#2) * fixing test message (#2) * fixing use of wrong variable and type * Update src/index.js - according suggestion :+1 Co-Authored-By: kazuya kawaguchi <kawakazu80@gmail.com> Co-authored-by: kazuya kawaguchi <kawakazu80@gmail.com>
close, due to release v8.17.0 |
See the |
Awesome, thank you very much ! |
🎉 Amazing! |
It would be nice to be able to specify fallback locale as an array that could cascade when falling back. For example, if someone selects "Canadian French" as their current locale, it would be nice to have a fallback locale of "French" and then an ultimate fallback of "English." This would be helpful for any locale that has sub-locales.
The text was updated successfully, but these errors were encountered: