Home > Articles > Programming > Java

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Apache Axis and I18N

You can use Java to access some powerful I18N techniques. An example of I18N use occurs with Apache Axis, the open-source SOAP server and client. Axis includes I18N support as a standard feature. If I want to add new text strings to Axis, I simply modify the source code and add an entry to a resource.properties file. The properties file contains translation and usage instructions with entries of the form <key>=<message>. Here is an example:

textstring00=Hello, my name is {0}, my job title is {1}

The element textstring00 is the key that the code uses to access this message. The text after the equals sign is the message text, and the {number} syntax defines the location for inserts in the code.

Next, I use the static method org.apache.axis.I18n.Messages.getMessage to obtain the text, and I add code inserts as required:

Messages.getMessage("textstring00", "John", "programmer");

The net effect is a string that looks something like this:

Hello, my name is John my job title is programmer

Using this mechanism, Axis has been I18N-enabled from the beginning of the project. This may turn out to be a pretty smart move on the part of the contributors because it could open up the project to a global user base.

I did say it's pretty easy to achieve this level of I18N capability. You can see that with a little planning, the text string numbering scheme (textstring00) could also be used to reserve blocks of numbers for different parts of your code, or even for various software products.

So, what about GUIs?

  • + Share This
  • 🔖 Save To Your Account