Skip to main content



      Home
Home » Eclipse Projects » Eclipse Scout » [neon] Changing user language programmatically
[neon] Changing user language programmatically [message #1755600] Mon, 06 March 2017 04:31 Go to next message
Eclipse UserFriend
In Scout Neon applications I can change the application's language by changing my browser language. This information also seems to be stored in a cookie with the name scout.preferredLocale.

Changing language therefore takes a change of the browser language and the deletion of the cookie.

Is there a way to offer the user a menu where they can choose their preferred language and then set this programmatically? Is there a way to persist this automatically, or would that be up to me? Is it just a matter of using NlsLocale.set() or NlsLocale.CURRENT.set()? Or is there more to it?
Re: [neon] Changing user language programmatically [message #1755915 is a reply to message #1755600] Thu, 09 March 2017 04:57 Go to previous messageGo to next message
Eclipse UserFriend
I created an example for the Contacts demo application with:
https://github.com/BSI-Business-Systems-Integration-AG/org.eclipse.scout.docs/commit/856adb2929c7e185a75de649ca346fe0d0855f2c

The most important part is that you set the locale in execLoadSession() of your AbstractClientSession implementation before the desktop is created.

public class ClientSession extends AbstractClientSession {
  public static final String PREF_USER_LOCALE = "PREF_USER_LOCALE";
  
  ...

  @Override
  protected void execLoadSession() {
    initializeSharedVariables();

    // The locale needs to be set before the Desktop is created.
    String localeString = ClientUIPreferences.getClientPreferences(ClientSession.get()).get(PREF_USER_LOCALE, null);
    if (localeString != null) {
      Locale userLocale = LocaleUtility.parse(localeString);
      setLocale(userLocale);
    }

    setDesktop(new Desktop());
  }
}


The solution with the OptionForm and the ClientUiPreferences is just one possibility. Of course you are completely free in terms of how to present the user with the choice and how to persist this setting.
Re: [neon] Changing user language programmatically [message #1756251 is a reply to message #1755915] Tue, 14 March 2017 10:30 Go to previous message
Eclipse UserFriend
Thanks Adrian, that works like a charm!
Previous Topic:Eclipse BIRT & Eclipse Scout "SVG Field" integration
Next Topic:[mars] docx4j - how to use
Goto Forum:
  


Current Time: Mon Jun 23 05:54:49 EDT 2025

Powered by FUDForum. Page generated in 0.04264 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top