The localize utility is a simple command-line tool created to help non-programmers to localize well-written JavaTM applications.
If a Java application is delivered using one or several .jar files and if some of these Jar files contain .properties resource files, the localize utility may be applied to the Jars. Note that Java source code is not needed, neither is a JDK (Java Development Kit).
For modularity reasons, Java applications are localized at the class (example: a dialog box class) or at the package level (example: a framework of tightly coupled classes) by creating a text file with extension .properties for each class or package to be localized.
These .properties files contain key=value pairs, where key is the identifier of a message, button label or menu item and value is the localized text.
Each language supported by the Java application must have its own .properties variant. Example: Foo.properties for the default language (generally English), Foo_fr.properties for French, Foo_es.properties for Spanish and so on.
For a mid-size Java application, one may end up with dozens of such .properties files. Without the help of the localize utility, adding support for a new language, say German, means creating dozens of *_de.properties files, which is tedious and error-prone.
Three steps are needed to localize a Java application:
++++++++++com/xmlmind/xmleditapp/TagChooserDialogRes.properties error=Error error= invalidTag={0} is not a valid name invalidTag= ----------com/xmlmind/xmleditapp/TagChooserDialogRes.properties ++++++++++com/xmlmind/xmleditapp/ValidityDiagToolRes.properties close=Close close= title=Check validity title= ----------com/xmlmind/xmleditapp/ValidityDiagToolRes.properties
++++++++++com/xmlmind/xmleditapp/TagChooserDialogRes.properties error=Error error= invalidTag={0} is not a valid name invalidTag= ----------com/xmlmind/xmleditapp/TagChooserDialogRes.properties ++++++++++com/xmlmind/xmleditapp/ValidityDiagToolRes.properties close=Close close= title=Check validity title= ----------com/xmlmind/xmleditapp/ValidityDiagToolRes.properties
++++++++++com/xmlmind/xmleditapp/TagChooserDialogRes.properties error=Error error=Erreur invalidTag={0} is not a valid name invalidTag={0} n'est pas un nom valide. ----------com/xmlmind/xmleditapp/TagChooserDialogRes.properties ++++++++++com/xmlmind/xmleditapp/ValidityDiagToolRes.properties close=Close close=Fermer title=Check validity title=Vérifier validité ----------com/xmlmind/xmleditapp/ValidityDiagToolRes.properties
The localize utility, while in the public domain, is fully supported by its author (hussein AT pixware DOT com).
The localize utility has been tested with:
Procedure:
$ cd $ unzip localize-12.zip $ ls localize-12 Localizer.java doc.html localize localize.bat localize.jar
$ su $ cp ~/localize-12/localize /usr/local/bin $ cp ~/localize-12/*.jar /usr/local/bin $ chmod a+rx /usr/local/bin/localize $ chmod a+r /usr/local/bin/*.jar
Install on Windows is similar to the install on Unix but under Windows you'll have to copy localize.bat rather than the localize shell script.
localize ?options? jar_or_dir_name
Extract mode options are:
Patch mode options are:
Other options are:
The reference language of XMLmind XML Editor (XXE) is English. This case study describes the localization of XXE in Spanish.
$ localize -x en_es.msg xxe_app.jar
The extracted message file is always encoded using the native encoding of the platform. Therefore, you can type accented characters as usual.
. . . styleSheetReloaded=Style sheet "{0}" reloaded. styleSheetReloaded= trimmingDocument=Stripping superfluous white space... trimmingDocument= undo=_Undo undo= untitled=Untitled untitled= userInput=User input userInput= viewClipboardContent=View Clipboard Content viewClipboardContent= window_menu=_Window window_menu= ----------com/xmlmind/xmleditapp/app/messages/Messages.properties ++++++++++com/xmlmind/xmleditapp/apt/messages/Messages.properties cancel=_Cancel cancel= defaultEncoding=_Default encoding: defaultEncoding= . . .
Notes:
In xxe_app.jar:
In xxe.jar (see step #5 below):
to localize the whole GUI of XXE.
In fact, certain sections (for example, com/xmlmind/xmledit/xsd which deals with validation of XML Schema) are very, very hard to translate and its better not to translate them.
Recommandations:
For example: in english, Alt-F opens the File menu because the underscored letter is F (i.e. _File). In german, the File menu is called Datei and the underscored letter should be D (i.e. _Datei).
Generating the same file for an already supported language may help you to better understand some of the messages.
For example, if you understands French as well as English, this command will extract all English messages to file en_fr.msg, each English message being followed by the corresponding French message (if any):
$ localize -x en_fr.msg -l2 fr xxe_app.jar
. . . userInput=User input userInput=Action Utilisateur viewClipboardContent=View Clipboard Content viewClipboardContent=Afficher Contenu du Presse-Papier window_menu=_Window window_menu=Fenêtre ----------com/xmlmind/xmleditapp/app/messages/Messages.properties ++++++++++com/xmlmind/xmleditapp/apt/messages/Messages.properties cancel=_Cancel cancel=_Annuler defaultEncoding=_Default encoding: defaultEncoding=_Encodage par défaut: . . .
This type of command must also be used if, for example, you have localized version 2.1 in spanish and want now to update your localization for version 2.2.
$ localize -p en_es.msg -l es xxe_app.jar $ ls . . . xxe_app.jar xxe_app.jar.BAK
Note the mandatory -l argument used to specify which .properties file are to be generated.
Edit the shell script xxe on Unix (xxe.bat on Windows) and add -Duser.language=es in the java command line if the default locale of your desktop is not es.