Introduction

Why?

Blame Struts. I was a happy, cheerful J2EE programmer (well, not that happy really, but cheerful indeed!) until I had to do some i18n. You know, message.properties, java.util.Locale, base Actions. A few things started to bother me a little bit.

  • Having to make up property keys.This is frustrating for me. When you use a properties file to hold your messages, you come up with something like: welcome=Welcome!

    This line alone seems awkward. I am only interested in the value part. But the left hand side is needed to make reference to the message in your JSP pages like:

    <bean:message key="welcome"/>

    Moreover. When an application holds hundreds of pages, you start wondering wether to use some kind of convention on the keys. Like path.to.jsp.message or something. And I am not good at sticking to conventions I find not useful.

  • Interrupting me constantly.I mean, you have your mind set on showing some presentation data, trying to orchestrate the whole composition of the view maybe using tiles, writing to standards of the web; there's quite a lot going on in your head. And you need to flow, to write things in the more natural way possible to keep focus. But for every single literal you write you need to go to a bulky properties file, make up a key, put a value, and restart Tomcat so the new entry is loaded (although I know there are workarounds for refreshing this). Bang! context's lost. Why not writing things as they are and delegate the i18n to some other framework? In other words, why not let the computer do something for you this time?
  • I am not the translator.I am not the graphical designer either, for a very good reason as you see. I have no skills in translating properly into a random language the app I'm writing. I realize passing the properties file to someone is not a big deal, but it actually has not happened that way till present day in my pro life. Can it be done in a different way?
  • Other languages do.I was extending some of the mail signing capabilities of Horde's IMAP when I stumbled over and over upon strange function calls like: _("Hello");. Reading some documentation I learned about gettext. I still don't know much about it, but it looks like it's just what I was looking for: A coding-time painless solution for translating an application.

How?

All right, enough personal frustration. I decided then it was time to come up with something simple but powerful. The following is a proposal for the architecture of the solution.

  • A text parser that knows how to extract what needs to be translated and leaves the rest unharmed
  • A specific translator. This project is not about automatic translation, but bringing existing implementations closer to the (web) application development.
  • A cache to keep already made translations and stop asking the translator every time.
  • A set of tools to correct misunderstood text on the fly, as painless as possible.

Get your hands on it!

Please go on and download the latest release of the t18n WAR demo run the example web application on a Servlet container such as Tomcat. You'll be surprised. It's Magic!