Change locale for anonymous user

Hi,
It’s possible to change locale for an anonymous user in jmix-2.2.3 ?

Thnxs.

Hi!

You can simply change the locale using the following method:

VaadinSession.getCurrent().setLocale(locale);

After this, you will need to reload the page to allow the components to change their localized messages.
If you do not want to reload the page, then you will need to implement a locale change listener for the current view. Use standard Jmix LoginView as an example:

@Route(value = "login")
@ViewController("LoginView")
@ViewDescriptor("login-view.xml")
public class LoginView extends StandardView implements LocaleChangeObserver {

    // some code

    @Override
    public void localeChange(final LocaleChangeEvent event) {
        // localization logic
    }
}

Best regards,
Dmitriy

Hi Dmitriy,
Locale change that you propose works fine but as soon as we choose a menu option, locale returns to default locale.
Best regards,
Francesc