Localization With Specify 6

Specify Software Project Staff
01 June 2010
Version 1.0

Java has extensions for supporting internationalizing and localizing applications. Although there are various APIs that can be used within the application, the most important aspect of localizing an application is translating the text used in the the graphical user interface (GUI) into the proper locale. Java takes a simple but effective approach to this: it uses 'named value' pairs. The 'name' is a key that the software uses to look up a text string in the current locale that is to be displayed to the user. The challenge for the developers is to make sure that all strings in the application have to be changed to use a 'locale' look up. The name/value pairs are stored in a text 'properties' file for each language localization.

The majority of Java applications that require localization simply create and populate a properties file for each required language. This is fairly simple and straight forward. The real challenge for large software applications is not the initial effort of localization, but the ongoing maintenance of the software. As each new release is shipped small but important changes in the application will require named/values pairs to be added, removed or edited. Locating the changes in the properties file can be daunting without the support of utility applications.

Specify 6 Tools for Assisting Localization

Specify 6 has three different areas that need to be localized:

  1. The strings in the application itself that are placed in a properties file.
  2. The forms that are displayed to the user (the forms that are defined in XML).
  3. The database schema (e.g. field names/titles that show up in the GUI).

Java Properties File

This section provides a small overview of how the java properties file work. As mentioned earlier, Java localizations are stored in text files 'properties'. A Java application can have a default localization.

Specify's SpecifyL10N

The Trifocal provides two import tasks:

  1. It enables the user to easily see both the original English text and the new editable localized text.
  2. It located differences from the previous localization and the current properties files.

Starting Up

When the application starts for the first time it will ask the user to choose a new localization. It will then create a new directory named 'I18N' in the user's 'My Documents' directory ('Documents' for the Mac, and at the root user directory for Linux). It then copies the original English files to and directory named 'en' and also creates a directory for the new localization (e.g. for Spanish it would be 'es'). Although the files in the localized directory can be edited with a text editor it is not recommended.

Specify requires that several files be localized SpecifyL10N will assist the user and managing all the files.

The Translation Screen

The following screen shot shows the main window of the SpecifyL10N. This a list of descriptions for each part of the screen that match the green numbers in the screen shot.

  1. The list of 'keys' in the properties file.
  2. The list of keys that are new or have changed.
  3. The name and location of the current properties file being localized.
  4. The English text to be translated.
  5. The text input box for the new translated text.
  6. The 'Translate' button that will use the Google Translate web service to auto-translate the text.
  7. A search box that will search the current translation for keys or text.
  8. The results of the search.

How to Translate Strings

The entire list of keys that need to be translated will appear in #1. Item #2 shows the list of new or changed items to be translated. The first time a file is opened for translation the two lists will be identical. The English string will be displayed in the text box #4 and the new translated text will be entered in text box #5. The 'Translate' button can be used to perform a quick translation using the Google Translate web service. Although the auto translations can seldom be used 'as-is,' it can save on typing.

Important - Must Read

As discussed earlier, Java properties files are 'name/value' pairs. This means that both the 'key' and the 'value' must both be stored on a single line in the file and therefore cannot contain any 'returns' or 'linefeeds.' If the 'value' portion of the text is too long and requires a new line the characters '\n' will be used. As each piece of text is translated it is important to note if the English version contains any '\n' characters. If so, you should place the '\n' in your translated text to approximate the same length of each line. In some cases, if the string is not 'broken up' using the '\n' then a dialog or label maybe appear too wide for the screen. Here is an example:

There was an error unlocking the form.\nYou may need to unlock the associated tree, if there is one.

Formatting

Some 'value' strings in the English translation contain addition special character sequences like: '%s' or '%d'

These strings are parameterized format strings, or in other words, the special characters sequence is replaced by a string or a number before the string is displayed. These must be left in and at the proper location to provide the intended information to the user. Here is an actual example:

The data in the field '%s' exceeds %d characters.

HTML

Some strings use HTML markup for their messages. It is important to leave in the HTML markup for the message to display correctly.

<html><i>(You may wish to place an '*' before or after the word(s), for a wild card search.)

The Menus

  1. Enables the user to switch to a different properties file (see next figure)
  2. Saves the current changes.
  3. Enables the user to create a new translation from scratch.
  4. If there is more than one translation in the I18N directory, it enables the user to change to a different translation.

 

The dialog shown above lists the available files that are to be translated. It is not a typical file chooser dialog.

The Form System

Most of the fields in the forms get their labels from the schema in the database. The Schema Config tool is used to localize the labels and the descriptions. There are a hand full of forms with fields that get their labels though the Java properties mechanism.

 

Specify's Schema Config Tool

(Coming Soon)