Changing Locale setting at runtime

N

napo

Hi,
I'm developing an RCP application based on Eclipse 3.3.
I wrote it down in my language and then I translated it using Externalize
mechanism in Eclipse.
When the application starts, a little login form appears. On that form
there's a combobox with a list of languages.
When I select a language I need to have the form (and the application)
translated on-the-fly, without restart or something else.
In the selection event of the combobox I wrote down:
Locale.setDefault(localeSelectedFromCombo);
but I want the application to be translated at runtime.

How can I do that?

Hi
Marco
 
T

Tom Hawtin

napo said:
Nobody knows?

I can't find your original post.

Anyway, assuming you want to set the default locale in a running Java
program:

If you do not have a security manager, you can use Locale.setDefault.
Obviously you wouldn't want, say, an applet to change the locale setting
for the whole JVM. It also wont update any cases where the default
locale has already been read.

A better way to do it is to read the default locale only once. As you
construct locale-sensitive objects, pass them an object that wraps
locale and allows callbacks (listeners) to be registered for changes.

Tom Hawtin
 
N

napo

I can't find your original post.

That's the original post.

I'm developing an RCP application based on Eclipse 3.3.
I wrote it down in my language and then I translated it using Externalize
mechanism in Eclipse.
When the application starts, a little login form appears. On that form
there's a combobox with a list of languages.
When I select a language I need to have the form (and the application)
translated on-the-fly, without restart or something else.
In the selection event of the combobox I wrote down:
Locale.setDefault(localeSelectedFromCombo);
but I want the application to be translated at runtime.

Hi
Marco
 
N

napo

You can set the system property that controls the locale on the

Mine is not a problem of configuration, I know how to change the locale.
The problem is about changing at runtime.
I made an example...
I have the login form on screen, and it's in english.
From the language combo box I choose Italian (or French, German, ...) and I
want the form to translate immediately.
I have already all the properties files with translations.

Hi
Marco
 
R

Roedy Green

Mine is not a problem of configuration, I know how to change the locale.
The problem is about changing at runtime.
I made an example...
I have the login form on screen, and it's in english.
From the language combo box I choose Italian (or French, German, ...) and I
want the form to translate immediately.
I have already all the properties files with translations.

see http://mindprod.com/jgloss/locale.html
 
T

Twisted

In a pinch you would programmatically exec another JVM with the
modified locale.

Are you mad?! One 260MB javaw.exe process is memory hog enough. Two at
the same time is going to be problematical on 1GB machines and
downright catastrophic on 512MB ones, where there'll be hours of
thrashing while the first one bootstraps the second one and both are
trying to be active simultaneously. Once the bootstrapper exits sanity
returns, but ... nobody likes an application that takes 72 seconds of
heavy disk activity to look like it's sorta beginning to maybe load,
and another 300 or so to actually load. :p

If you must programmatically exec the JVM with your main application
with a UI-determined locale from a bootstrapper, for Christ's sake
code the bootstrapper in C! It'll be all of 30KB that way, or around
1/1000 the size.

Java simply doesn't scale well to program sizes smaller than major
applications, when a normal (rather than micro edition) JRE is used.
 
R

Roedy Green

Are you mad?! One 260MB javaw.exe process is memory hog enough

I was presuming the spawner would exit, like a salmon dying after
laying eggs. Even if that is not possible without killing the child,
the spawner would page out of ram fairly quickly. Further much of
javaw is now a shared DLL.
 
T

Twisted

I was presuming the spawner would exit, like a salmon dying after
laying eggs.

They still run simultaneously for a while, with neither of them idle
during part of that time.
Even if that is not possible without killing the child, the spawner would page out of ram fairly quickly.

Once it goes idle.
Further much of javaw is now a shared DLL.

Yep - all 132KB or so of it. The 259.8 or so remaining MB of process
size being the big Java heap a separate one of which is created for
each separate running virtual machine, as near as I can figure.
 
Joined
Sep 23, 2008
Messages
2
Reaction score
0
Similar problem, plz help

Hey Marco,
I am also working on RCP apps & now facing same requirement you faced. So if you can provide info. how you solved that or any info. on that how to approach or any alternative, that would be great. Thanks in advance & expecting a reply from your side.

regards
Chats
 
Joined
Sep 23, 2008
Messages
2
Reaction score
0
Hey Marco,
I am also working on RCP apps & now facing same requirement you faced. So if you can provide info. how you solved that or any info. on that how to approach or any alternative, that would be great. Thanks in advance & expecting a reply from your side.

regards
Chats
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,246
Members
46,840
Latest member
BrendanG78

Latest Threads

Top