The official way to language switch

I have a web app that should be done in two langages, I have two button to switch langage. Once the locale is set, how do I refresh the UI so all labels and other components are changed to the new language?

What is the official way that you though of for this situation? I search the forum and there is only old Vaadin6 solutions, What is the Vaadin7 way of doing things?

P.S. It would be interesting to have the Dashboard demo being multi-language to show us how you have done it.

Looks to me language switch in Vaadin is mainly a case of “pick your own poison”. There seems to be no “Vaadin-way” for it but there are some I18N addons available, maybe one of them fits your use-case.

As far as I’m concerned, we use Vaadin-CDI with the CDI-properties addon which allows to add (among other things) a caption-key to injected components.
On a language change we use reflection to look for components that have a caption-key, load the caption for that key from the language-bundle for the new locale and set the new caption.

Like you said, I have picked my poison, here is what I did:

All my views are @UIScope, so I decided to close the current UI and reload the page. It’s not that elegant but it is simple and it works:

        public void englishSelected( final EnglishSelected pEvent ) {
            setLocale( Locale.ENGLISH );
            I18N.setLocale( Locale.ENGLISH );

The I18N class here is an utility class that contain my ressource bundle. The side effect of this solution is that the user see the page being refreshed but that is not so bad.

Now…how to do same in vaadin 11??? :frowning: