Hi,
I am building my first Gui with Swing, and in the same time I need to
use the i18n to make it work in Japanese and English.
I use Eclipse and its great Visual Editor to save time, all my files are
utf8 encoded. And, I am under WinXp...
My trouble is the following :
-> If I make a jMenu with some japanese hardcoded text, it appears fine
in my application.
-> If I use a ResourceBundle to get the text, I have garbage. I use the
following line: myMenu.setText(myBundleResource.getString("myTest"));
The .properties files for the japanese is also in Utf8
Do you have any idea why the text in the .properties file is not passed
correctly ? Any help would be really appreciated.
Best Regards,
Schlum
hiwa - 12 Jun 2006 06:58 GMT
Schlum :
> Hi,
>
[quoted text clipped - 16 lines]
> Best Regards,
> Schlum
Did you use native2ascii tool for creating the ja.properties?
Do you set Locale.ja in your application?
Schlum - 12 Jun 2006 07:07 GMT
> Schlum のメッセージ:
>
[quoted text clipped - 20 lines]
> Did you use native2ascii tool for creating the ja.properties?
> Do you set Locale.ja in your application?
Hi, thank you for your answer,
I actually do not know what is native2ascii, I am going to look at it
right away.
Here is the way i did it:
I declared a private ResourceBundle messages into my gui class:
private ResourceBundle messages;
I then initialize it in the constructor of my class:
String langue = new String("ja");
String pays = new String("JP");
Locale currentLocale= new Locale(langue, pays);
this.messages = ResourceBundle.getBundle("messages", currentLocale);
The languages files are messages.properties, messages_ja_JP.properties
and messages_us_US.properties. They are in the path, as I can display
the English correctly.
For the moment, I do not detect the computer's local as I am developing
in a English environment.
Do you see something wrong in the way i did this ?
Thank's for your help,
Schlum.
hiwa - 12 Jun 2006 08:02 GMT
Schlum :
> > Schlum :
> >
[quoted text clipped - 49 lines]
> Thank's for your help,
> Schlum.
The messages_ja.properties file should be prepared by using
native2ascii tool or \uxxxx notation for Japanese characters.
Thomas Weidenfeller - 12 Jun 2006 08:12 GMT
> The .properties files for the japanese is also in Utf8
Bad. It needs to be in ASCII/Latin-1 with any non ASCII/Latin-1 char
encoded with the \u notation.
This is difficult to write by hand, so use native2ascii to convert your
text. I would recommend to add the call to native2ascii to your build
system.
> Do you have any idea why the text in the .properties file is not passed
> correctly ?
Because you didn't write it correctly.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
Schlum - 12 Jun 2006 08:54 GMT
Hiwa, Thomas,
Thank you very much for your help, it works perfectly now.
Have a good day,
Schlum
> Hi,
>
[quoted text clipped - 16 lines]
> Best Regards,
> Schlum
John O'Conner - 12 Jun 2006 15:23 GMT
Do you have any idea why the text in the .properties file is not passed
> correctly ? Any help would be really appreciated.
You may find this article helpful to create and use ResourceBundle files
correctly:
http://java.sun.com/developer/technicalArticles/Intl/ResourceBundles/index.html
Regards,
John O'Conner
Per1000IPDay8@126.com - 12 Jun 2006 15:49 GMT
EnergyKey
------------------------------ ------------------------------
------------------------------
http://www30.webSamba.com/SmartStudio
------------------------------ ------------------------------
------------------------------
Save yourself from repetitive tasks