Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2008

Tip: Looking for answers? Try searching our database.

Internationalization

Thread view: 
Mark - 25 Jan 2008 15:42 GMT
I was informed today that my Java program might be used in several other
countries, including China, Romania, and some Spanish-speaking countries
in South America.

This mostly impacts the GUI where I have menu items, tool-tips, and
dialog messages -- all in English, currently.

I haven't a clue what I should do to make my GUI internationalized.  I
am seeking guidance on this...

I read the article at:
http://java.sun.com/developer/technicalArticles/J2SE/locale/ but it
didn't explain how I would most wisely go about making my drop-down text
menu available in several different languages.

Say, to make the "File" menu and the "Edit" menu use different words
depending on the Locale setting, would I have to create a lengthy
if{}-else{} block to test for each Locale supported and return a
translated String for each word?  If so, in my case with a lot of
text/words, this would be extremely cumbersome and the code would
probably triple in size.  It might be less tedious if I were to maintain
multiple versions of the software (in each language).  Am I missing
something?

Mark
Bent C Dalager - 25 Jan 2008 17:02 GMT
>Say, to make the "File" menu and the "Edit" menu use different words
>depending on the Locale setting, would I have to create a lengthy
>if{}-else{} block to test for each Locale supported and return a
>translated String for each word?

No, you use resource bundles and possibly the MessageFormat class for
this.

See
http://java.sun.com/j2se/1.5.0/docs/api/java/util/ResourceBundle.html
and
http://java.sun.com/j2se/1.5.0/docs/api/java/text/MessageFormat.html

This way, your code may change from something like
button.setText("Apply");
to
button.setText(bundle.getString("button.apply"));

And you will have a Strings.properties file that would contain,
amongst other things,

button.apply = Apply

Then you might have one Strings_es_ES.properties file with Spanish
strings, etc.

Cheers,
    Bent D
Signature

Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
                                   powered by emacs

Mark - 25 Jan 2008 18:23 GMT
> No, you use resource bundles and possibly the MessageFormat class for
> this.
[quoted text clipped - 16 lines]
> Then you might have one Strings_es_ES.properties file with Spanish
> strings, etc.

Awesome!  Exactly what I was looking for!  TY!

Mark
Thomas A. Russ - 25 Jan 2008 20:07 GMT
> I was informed today that my Java program might be used in several other
> countries, including China, Romania, and some Spanish-speaking countries
> in South America.
>
> I haven't a clue what I should do to make my GUI internationalized.  I
> am seeking guidance on this...

You should also look at what support is available for
internationalization in your particular IDE.  For example, NetBeans has
tool support for internationalization.  I haven't tried them, but that
may certainly help you in automatically setting up the proper
infrastructure for the internationalization of the text.

> Say, to make the "File" menu and the "Edit" menu use different words
> depending on the Locale setting, would I have to create a lengthy
[quoted text clipped - 4 lines]
> multiple versions of the software (in each language).  Am I missing
> something?

You use properties files as Bent Dalager suggested.  It also makes it a
LOT easier to add additional languages, since only the property files
need to be handled by the translator, and not the entire code base.

This also helps in development, since it makes it simpler to change the
wording on buttons, prompts and message strings in response to user
feedback.

Signature

Thomas A. Russ,  USC/Information Sciences Institute

Roedy Green - 27 Jan 2008 03:31 GMT
>I haven't a clue what I should do to make my GUI internationalized.  I
>am seeking guidance on this...

see http://mindprod.com/jgloss/localisation.html
Signature

Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com

Roedy Green - 27 Jan 2008 03:32 GMT
>I was informed today that my Java program might be used in several other
>countries, including China, Romania, and some Spanish-speaking countries
>in South America.

see http://mindprod.com/jgloss/resourcebundle.html
Signature

Roedy Green, Canadian Mind Products
The Java Glossary, http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.