How to use NLS support

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

How to use NLS support

Postby Kelly » Thu Feb 28, 2008 8:34 am

I have watched the demo and understand how to use it. Nice and simple, good work.

But my problem is I want to which languages in my application when the user selects a language.

I the Messages.java class created by Designer does not support this.

I used the Classic Eclipse method when I created the NLS.

Am i missing something or do I have to write my own Messages.java class to support switching languages on the fly?

Thanks
Kelly
 
Posts: 38
Joined: Wed Feb 02, 2005 8:22 am

Re: How to use NLS support

Postby Eric Clayberg » Thu Feb 28, 2008 9:50 am

I don't believe that any of the common NLS patterns support dynamic language switching like that.

All of them work under the principle of showing strings matching the current locale when a window is opened.

If you want to dynamically switch strings on the fly, you woud need to implement that entirely yourself.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: How to use NLS support

Postby Kelly » Thu Feb 28, 2008 10:21 am

Thanks for your quick reply.

I guess 'on the fly' was a poor choice of words.

What I am wanting is a language selection screen to be displayed first and the user would select a language. I would then change what the Message.java class loads as a resource.
Then all screens displayed after that would be in the language they selected.

As the Message.java class is coded I would have to hand edit the resource being loaded and then recompile the package or am I not using the code generated correctly?

If I have to rewrite Message.java to handle changing the language then I will do that but it seems to me that the code being generated should be changed to support something like what I am wanting.

It just seems to me that you missed the last step of the NLS process but I am new to NLS so I could be wrong.

Thanks
Kelly
 
Posts: 38
Joined: Wed Feb 02, 2005 8:22 am

Re: How to use NLS support

Postby Eric Clayberg » Thu Feb 28, 2008 12:11 pm

The code as generated exactly follows the "classic Eclipse" NLS pattern which loads resources based on the current, default locale which is already established at the time the application starts (and is typically not expected to change while the application is running). Switching languages (locales) after the app has started up is not typical behavior and something you would need to code by hand. None of the common NLS styles that Designer offers gode gen for support that kind of behavior by default. You are correct that if you want to support language switching, you would need to add some additional behavior to the Messages class. In particular, you would need to be able to set the current locale and then load the appropriate resource bundle based on that locale. None of the code in the GUI classes should need to change.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 2 guests