Friday, October 30, 2009

Chinese characters in resource bundles

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 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

The file will contain Unicode characters for your Chinese letters in Then copy the content in file and copy it to any file created in eclipse.

The program will work fine displaying Chinese characters without any modification to source code.


  1. This comment has been removed by a blog administrator.

  2. Can you not create 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.