Hi, everyone.
I'm currently creating a program that will be translated to at least three
different languages. I want it to be possible to change languages on the
fly. So far I've been using Runnables that set the texts on all components
when the language is changed. Is that the way to go or is there something
simpler that I have missed so far?
Thanks,
David
CK - 08 Mar 2008 16:23 GMT
Words to the wise, David Bombe Roden <bombe@pterodactylus.net>
wrote:
>Hi, everyone.
>
[quoted text clipped - 3 lines]
>when the language is changed. Is that the way to go or is there something
>simpler that I have missed so far?
You could implement a controller which just listens to whether the
language is being changed and which then iterates over all controls
and sets the corresponding string from a resource bundle depending on
the new language string. Whether that is simpler than your solution, I
cannot say.
--
Claus Dragon <clauskick@mpsahotmail.com>
=(UDIC)=
d++ e++ T--
K1!2!3!456!7!S a29
"Coffee is a mocker. So, I am going to mock."
- Me, lately.
Roedy Green - 21 Mar 2008 13:08 GMT
On Sat, 08 Mar 2008 14:45:44 +0100, David Bombe Roden
<bombe@pterodactylus.net> wrote, quoted or indirectly quoted someone
who said :
>I'm currently creating a program that will be translated to at least three
>different languages. I want it to be possible to change languages on the
>fly. So far I've been using Runnables that set the texts on all components
>when the language is changed. Is that the way to go or is there something
>simpler that I have missed so far?
see http://mindprod.com/jgloss/localisation.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Karsten Lentzsch - 22 Mar 2008 10:52 GMT
> see http://mindprod.com/jgloss/localisation.html
Just a note about internationalization and localization.
These are not the same. The first is the process of
preparing a system for different locales, where the second
is the concrete work where the prepared system gets support
for a new locale.
-Karsten
Roedy Green - 09 Apr 2008 06:55 GMT
On Sat, 22 Mar 2008 10:52:33 +0100, Karsten Lentzsch
<karsten@jgoodies.com> wrote, quoted or indirectly quoted someone who
said :
>> see http://mindprod.com/jgloss/localisation.html
>
[quoted text clipped - 3 lines]
>is the concrete work where the prepared system gets support
>for a new locale.
Thanks. I have added that observation to the entry.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Karsten Lentzsch - 22 Mar 2008 10:50 GMT
> I'm currently creating a program that will be translated to at least three
> different languages. I want it to be possible to change languages on the
> fly. So far I've been using Runnables that set the texts on all components
> when the language is changed. Is that the way to go or is there something
> simpler that I have missed so far?
You don't necessarily need Runnables. You can change
localized texts in the Event-Dispatch-Thread.
A workable approach is to have custom components,
for example an on-the-fly-label that stores a key
for the text lookup, listens to a custom property
that notifies the component when the Locale has changed.
On Locale change, the component can update its text
by re-reading the resource for its key.
Note that Locale has no bound property that can be
observed for that case. So a common approach is to
set a new Locale and then fire a change in a custom
(bean) property somewhere.
-Karsten