Skip to main content

Localizing MyJxta2

Posted by joconner on December 15, 2004 at 9:39 PM PST

The JXTA group just released a new version of their product, version 2.3.2, code name "Imam Bayaldi." What a name! A quick Google search on Imam Bayaldi tells me that this is an eggplant and tomato recipe...but that's another subject.

One of the key demo applications included in the download is a program called MyJxta2. It's essentially a chat application, with lots of interesting features. My reason in bringing this up is that the author took some of my advice concerning internationalization. He separated his UI text from his core source code and placed the key/value pairs into a PropertyResourceBundle. This allows you, the user community, to localize the product into your language, whether that language be Spanish, German, French, or ...well, you get the picture.

How do you take advantage of this? How do you translate MyJXTA2?

  1. After downloading the source, find the resource bundle at net.jxta.myjxta2.resources.text.text.properties.
  2. Load the text.properties file into your favorite editor.
  3. Without changing the keys on the left, edit the values on the right to corresponding terms in your target language.
  4. Save the text.properties file as text_.properites or text__.properites if your language is specific to a particular region. Some languages, even English, can use different terms for the same object, ie car hood (en_US) and bonnet (en_UK). So sometimes the 3166 code is necessary.
  5. Use native2ascii to convert the file to \uXXXX notation if your character set is anything other than ISO 8859-1 or Latin-1.
  6. Submit the result to dev@myjxta2.jxta.org.

Here are a few entries from text.properties:

label.color=Color
label.color.red=Red
label.color.blue=Blue
label.color.black=Black

Editing this in my editor, and translating to Japanese, I might write this:

label.color=色
label.color.red=赤
label.color.blue=青
label.color.black=é»’

Now, what's next? We save the file of course. Since this is Japanese, we save the file as text_ja.properties. My editor can save files in a variety of charsets. Let's asssume I saved the file in the SJIS charset. Your editor may only save to your local charset. Once you save the file, there's just one problem...Japanese cannot be represented natively in Latin-1. So, I have to use the native2ascii tool to convert this file from a native encoding like Shift-JIS, JIS, or maybe even a Unicode encoding like UTF-8 to \uXXXX notation that is ASCII compatible. I can use this tool like so:

native2ascii -encoding SJIS text_ja.properties foo.properties
mv foo.properties text_ja.properties

Now the text_ja.properties file still contains the Japanese localized text, but it has been converted so that it can be used by the Java platform. Of course, it does look a little different in an editor:

label.color=\u8272
label.color.red=\u8d64
label.color.blue=\u9752
label.color.black=\u9ed2

Place this file (text_ja.properties or whatever you've created) into your source package for resources, build, and you have a MyJxta2 app capable of displaying its UI in Japanese. Impressive.

Hava some fun creating your own localization of MyJxta2. Don't forget to contribute back to the JXTA community by sending your localized file to dev@myjxta2.jxta.org!

Related Topics >>