How to edit resource bundle in Eclipse

All professional Java programmer knows how to deal with i18n. Unfortunately, I am not a professional programmer in Java. I still feel like character encoding and character set in Java is a kind of messy setting. It is as simple as I get in other language like C, Python, PHP or etc. For example, developing a JSP involves character encoding in many factors, e.g., the source of JSP itself, the virtual machine, the external files, the database, the content in database, the application server, resource bundle, message bundle and many more. This post will focus on resource bundles and message bundle for i18n support in JSP and other kind of Java application including JSF and Struts.

First thing you have to realize in the deepest mind. Resource bundles and message bundles are usually stored in files with extension .properties. The format of properties file is very simple and you may use any text editors to edit them.

key=value

Above is the basic format. Usually, it will be placed in MessagesBundle.properties and other languages will be saved in MessagesBundle_th.properties for Thai language (th). The trick is here. Everything goes well as long as all characters are in western character set. Unfortunately, I am Thai and Thai character set is beyond ASCII. This is a kind of known problem with workaround solution. All properties file only accepts ASCII. We have to convert other character sets to ASCII in such a way. The way that Java selected is to encode them in Java way (see below).

key=\u0E01\u0E02\u0E03\u0E04

In other words, this is not a human duty to write texts in unicode number. No way! So we need converter or editor that know what to do.

  • Resource Bundle Editor
  • native2ascii is bundled with JDK
  • UniRed

I found these tricks at Narisa.

Tags: , , , ,

Post new comment