How to change programaticaly the localization of the App

Hi,

I’m trying to change le locale programaticaly , but it seems not to work :

@Subscribe("localesField")
    public void onLocalesFieldValueChange(HasValue.ValueChangeEvent event) {
        Locale locale = (Locale)event.getValue();
        log.info(locale.toString());
        if (locale != null && !locale.equals(jmixApp.getLocale())) {
            App.getInstance().setLocale(locale);
              App.getInstance().createTopLevelWindow(AppUI.getCurrent());
        }
    }

private void initLocalesField() {
        localesField.setOptionsMap(messageTools.getAvailableLocalesMap());
        localesField.setValue(jmixApp.getLocale());
    }

It’s not working, my app is already in English.
I’m using jmix 1.4 and OIDC (keycloak) plugins

Best regards

Alexandre

I try with jmixApp too, but this does’nt working.

Hello Alexandre

I had a similar problem while developing my CUBA application. Maybe the information from Gleb from Jan 21, specifically the code…

app.createTopLevelWindow();

in the following post can help you…

Best regards
Chris

Hi Chris,

thanks for your response, I do the same thing In my code, I have try this

App.getInstance().setLocale(locale);
App.getInstance().createTopLevelWindow(AppUI.getCurrent());

or

jmixApp.setLocale(locale);
jmixApp.createTopLevelWindow(AppUI.getCurrent());

this operation refresh the screen, but doesn’t change the language

Hi,

Could you please attach a small demo project that reproduces the issue?

Regards,
Gleb