×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    3

    LWUIT L10n not working?

    Hi, We are trying to build a nice localization feature in an app with LWUIT.

    However we have found an extrange behaviour when swapping languages.

    Trying to reproduce outside our app, we have used the "Autolocalization" https://projects.developer.nokia.com...toLocalization example from tkor/tuokor and extended a bit to show that annoying pattern.

    Basically, when changing locale (language) it looks like it keeps last non-"en" language, but skips "en" if you try to set it as the default language for localization.

    Here is the full code:

    Code:
    /**
     * @author tkor
     */
    public class Midlet extends MIDlet {
    
        public void startApp() {
            Display.init( this );
            Form f = new Form( "localized" );
            System.out.println( System.getProperty( "microedition.locale" ) );
            try {
                // Default language: this should print "Hi" if default language in "microedition.locale" is "en"
                // -> It prints "Hi", OK
                Label l = new Label(UIManager.getInstance().localize( "hello", "Hello" ) );
    
                // Set language to "en": this should print "Hi"
                // -> It prints "Hi", OK
                UIManager.getInstance().setResourceBundle( Resources.open( "/locale/locale.res" ).getL10N( "locale", "en" ) );
                Label l2 = new Label(UIManager.getInstance().localize( "hello", "Hello" ) );
    
                // Set language to "fi-FI": this should print "Moi"
                // -> It prints "Moi", OK
                UIManager.getInstance().setResourceBundle( Resources.open( "/locale/locale.res" ).getL10N( "locale", "fi-FI" ) );
                Label l3 = new Label(UIManager.getInstance().localize( "hello", "Hello" ) );
    
                // Set language to "en" again: this should print "Hi"
                // -> It prints "Moi", NOT OK !!!
                UIManager.getInstance().setResourceBundle( Resources.open( "/locale/locale.res" ).getL10N( "locale", "en" ) );
                Label l4 = new Label(UIManager.getInstance().localize( "hello", "Hello" ) );
                // Tested with some other locale files and always keeps last non-"en" value
                // Does work setting "en" value at all?
    
                f.addComponent( l );
                f.addComponent( l2 );
                f.addComponent( l3 );
                f.addComponent( l4 );
            } catch( Exception e ) {
            }
            f.show();
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp( boolean unconditional ) {
        }
    }
    Has anyone faced this issue? Is it a bug? Is it a bug in our code/understanding... or what? Thanks.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: LWUIT L10n not working?

    While it is not necessarily the latest source, https://projects.developer.nokia.com...UIManager.java does not do anything special in its localize method (line 1339), and setResourceBundle (line 1221) sets the actual container variable pretty soon (given that localeAccessible stays true - its default value).
    You may want to check what "Resources.open( "/locale/locale.res" ).getL10N( "locale", "en" )" produces. Resources.open (https://projects.developer.nokia.com...Resources.java, line 537) has some caching mechanism, but that should be Ok I think. And getL10N is a one-liner (line 637), it seems rather innocent to me.
    And in particular I can not see any special treatment for "en", except for assuming it default at the end of UIManager.java (method loadLocalization).

Similar Threads

  1. LWUIT VKB not working in landscape orientation
    By da32x in forum Mobile Java General
    Replies: 2
    Last Post: 2013-04-22, 11:23
  2. Which components are L10N compatible?
    By nummesam in forum Mobile Java General
    Replies: 0
    Last Post: 2013-03-28, 12:35
  3. Replies: 2
    Last Post: 2012-11-23, 07:39
  4. Command is not working on LWUIT Form Screen
    By pavanragi in forum Mobile Java General
    Replies: 1
    Last Post: 2012-08-12, 21:59
  5. nokia l10n bug (ml_IN)
    By jaganadhg in forum Series 40 & S60 Platform Feedback Archive
    Replies: 1
    Last Post: 2008-08-27, 18:12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •