How to Localize

Localizing to Other Locales

Localizing JSwat to other locales should be quite simple. Nearly all of the user-readable strings in JSwat are stored in files called Bundle.properties in the various directories. These files define the strings for the default language, English. Strings for other locales must be defined in separate files, using a file naming convention as described in the documentation for the java.util.ResourceBundle class. That information is reprinted here for convenience.

Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales. For example, the base name of a family of resource bundles might be "MyResources". The family should have a default resource bundle which simply has the same name as its family - "MyResources" - and will be used as the bundle of last resort if a specific locale is not supported. The family can then provide as many locale-specific members as needed, for example a German one named "MyResources_de".

Each resource bundle in a family contains the same items, but the items have been translated for the locale represented by that resource bundle. For example, both "MyResources" and "MyResources_de" may have a String that's used on a button for canceling operations. In "MyResources" the String may contain "Cancel" and in "MyResources_de" it may contain "Abbrechen".

If there are different resources for different countries, you can make specializations: for example, "MyResources_de_CH" contains objects for the German language (de) in Switzerland (CH). If you want to only modify some of the resources in the specialization, you can do so.

The steps for localizing JSwat to another locale should be rather straightforward. Start by copying each Bundle.properties file to a new name, as described above, and modifying the strings after the equals sign (=) on each of the lines in the file. There are some lines that need not be modified, they are pretty obvious when you see them. These include the lines that define the menu structure and toolbar button ordering.

After you have created new Bundle.properties files, you may launch JSwat on a platform implementing the desired locale. The Java VM should detect the native locale and display the appropriate user-visible strings. See this page for instructions on compiling and running JSwat.

File Format

If you are not familiar with Java resource bundles, the file format goes something like this:

#
# Comment lines start with a '#'
#
key1 = value1

key2 = value2 \
on multiple \
lines.

key3 = value3 \n with \t character escapes.

As you can see, the strings are referenced by a name (e.g. "key1", "key2"), followed an equals sign (=) and the localizable string. The string may contain slash-escapes. When a line ends with a slash, it means the next line is also a part of the value.