-
Notifications
You must be signed in to change notification settings - Fork 176
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
VaadinSession uses first provided Locale which breaks the default bundle usage #20967
Comments
I guess the problem is related to the fact that some Locale still needs to be picked and there's no way of knowing which one to use for the default bundle. I wonder if it would be reasonable to change We would then also have to make sure we remove duplicates (since there might also be a non-default bundle for the default locale) and put the default locale as the first one in the list. |
I don't understand why your mechanism is so complicated. Why do you even need to know the locales? Isn't the default behavior just good enough? https://docs.oracle.com/javase/tutorial/i18n/resbundle/concept.html |
I just disable this mechanism by returning an empty List:
|
We're limiting the automatic choice to a list of application-provided locales because of components like The idea of initializing the list based on available bundles is to automatically configure those components based on the locales that the application supports while avoiding unsupported ones. But there's indeed a problem with the default bundle since we can't know how those components should be configured when that bundle is used. This makes me think that |
In my experience using the DatePicker or DateTimePicker without explicitly configuring I18N doesn't work. |
I guess that's because it doesn't know what locale to use for the default case. If you have a suitable example project close by, then you could try using |
The problem with the DatePicker is a bit more complex because of the language and the formatting. The formatting depends on the Country, not the language. So we use resource bundles without the country code, and the one without the language is the default, which is usually German. For the DatePicker, we configure this and the parsing format.
|
Does If not, then that's probably something we should try to fix (but that's a separate ticket). And if that works as expected, then one partial solution for your case might be to explicitly list the Swiss locales rather than ones with only language but no country (but we'd still have to do something about the default language as well). |
Description of the bug
If a i18n provider is available, the locale is determined by selecting the locale from {@link I18NProvider#getProvidedLocales()} that best matches the user agent preferences (i.e. the <code>Accept-Language</code> header). If an exact match is found, then that locale is used. Otherwise, the matching logic looks for the first provided locale that uses the same language regardless of the country. If no other match is found, then the first item from {@link I18NProvider#getProvidedLocales()} is used.
This initially breaks the default behavior of the Java ResourceBundle.
Typically, a translations.properties without language is provided as a catch-all translation bundle.
Expected behavior
If we have translations_de.properties and translations.properties and the user has a language with no specific resource bundle, the translations from the translations.properties file must be used.
Minimal reproducible example
https://github.com/simasch/vaadin-default-translation-provider-bug
Versions
All versions since DefaultI18NProvider
The text was updated successfully, but these errors were encountered: