Localize component captions

What is the best (and easiest) known way to localize the GUI of a Java application.

I want the caption of the buttons, the menus, the error messages ... etc. to be dependent on the language selected by user. Also I want the orientation of the components to depent on the input language. For example, English is left-to-right but Arabic is right-to-left.

How can I do this from within the program with best effort (I don't want to rewrite so many things). Also I use Visual Editor for Eclipse in my GUI if this may help.

--

Regards,

Ahmed Saad

[580 byte] By [Ahmed.Saada] at [2007-10-1 13:09:42]
# 1

Ahmed,

The best way is to use ResourceBundles. To be fair, internationalisation is a fairly large topic, and so I can't recommend Java Internationalization by Andy Deitsch and David Czarnecki (O'Reilly) highly enough. Follow the link to the book web page (http://www.oreilly.com/catalog/javaint/) and you'll see that the sample chapter is all about ResourceBundles!

Also on that web page you'll find a link to that will allow you to download all the code samples from the book. Download it and unzip. Go into chapter 9 and open SimpleExample.java. Edit line 370 so that it says:

SimpleExample.applyComponentOrientation(SimpleExample.getFrame(), co);

Otherwise it won't compile. Compile it and run. I think this example really sums up how to go about internationalising your program. It demonstrates the use of ResourceBundles to store language specific lables for all your GUI text. Shows how to change language "live", whist the program is running. Illustrates some other interesting things from java.text. For example, language-specific sorting. Alphabet sort order for say French is (slightly) different to English (due to the accents in French), etc. This can be important of course.

Anyway, check it out. Also, the Java I18n tutorial is useful: http://java.sun.com/docs/books/tutorial/i18n/

HTH,

Andy

arooarooa at 2007-7-10 15:55:23 > top of Java-index,Desktop,I18N...
# 2
Thanks Andy, You are very helpful. I will check all this out and I think it will goes well.Thanks again.--Regards,Ahmed Saad
Ahmed.Saada at 2007-7-10 15:55:23 > top of Java-index,Desktop,I18N...