I had a difficult time to implement Chinese characters for my SWT application. I was using resource bundle for internationalizing the application. While creating resource bundles for Chinese characters I noticed that resource bundles will accept only ASCII and Java is not able to read UTF-8 resource bundles.I was using eclipse as my development IDE.
The following work around helped me to overcome the situation.
Open an existing MessageBundle.properties file outside eclipse using notepad. Enter Chinese characters for the translation you want and save the file in UTF-8 format. You can use google translation for getting the chinese characters.
The following work around helped me to overcome the situation.
Open an existing MessageBundle.properties file outside eclipse using notepad. Enter Chinese characters for the translation you want and save the file in UTF-8 format. You can use google translation for getting the chinese characters.
Use the tool 'native2ascii' to convert the chinese charcters to unicode characters.
The syntax is like this:
C:\temp>native2ascii -encoding utf-8 MessagesBundle.properties Chinese.properties
The Chinese.properties file will contain Unicode characters for your Chinese letters in MessageBundle.properties. Then copy the content in Chinese.properties file and copy it to any MessageBundle.properties file created in eclipse.
The program will work fine displaying Chinese characters without any modification to source code.
The program will work fine displaying Chinese characters without any modification to source code.
http://forums.sun.com/thread.jspa?threadID=306155
http://forums.sun.com/thread.jspa?threadID=212238&tstart=121351
http://java.sun.com/developer/technicalArticles/Intl/IntlIntro/
http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html
This comment has been removed by a blog administrator.
ReplyDeleteCan you not create MessageBundle.properties with appropriate extensions (MessageBundle.properties_FR , MessageBundle.properties_CN, ..) for various languages(character set), and depending upon the locale the application will use the appropriate message bundle.
ReplyDelete