getLocale() returns windows language and not accept-language

I have a component that uses a formatter based on Component.getLocale(). getLocale() always returns my windows display language and not my browsers first accept-language. Is this the desired way? I would assume that users browser language overrules the OS-language. I have no I18NProvider

Vaadin only picks from the available locales provided by the I18NProvider. If there isn’t one, it picks Locale.getDefault().

If you don’t want to implement a I18NProvider, there is another way to change that behavior.

You can thumbs up

which other way?

I was going to suggest a UIInitListener and then using VaadinRequest.getCurrent().getLocale() to set the locale you want on the UI. But if the VaadinRequest doesn’t work…hmm.

If you’re using Spring you could try the LocaleContextHolder. It’s initialized with the locale of each request.

Thanks, I will go for the (empty) I18NProvider that accepts all possible languages, so vaadin picks the accept-language…

I just tried this and it worked for me:

public class ServiceListener

public void serviceInit(ServiceInitEvent event)
event.getSource().addUIInitListener(initEvent →
Locale locale = VaadinRequest.getCurrent().getLocale();


So it’s at least worth trying.