Protege Resource Bundles
This articles describes Protege's support for internationalization using Java resource bundles.
The mechanisms described on this page are used to replace "fixed text" in the Protege user interface. Fixed text includes things like menu items, tab names, labels, and dialog titles. This is not a mechanism for authoring ontology and knowledge-base content in multiple languages simultaneously. Such support is entirely separate and documented elsewhere on this wiki.
Most of the fixed English text in the Protege user interface can be replaced with text from other languages. We also provide easy, standard ways for Protege plug-ins to provide internationalization support so that end-users can localize plug-in text. Currently, there are French and Russian resource bundles available for download from our Subversion repository:
If you develop a Protege resource bundle, please consider contributing it back to the Protege user community. We will be happy to host resource bundles in our source code repository.
Protege's support for internalization and localization is directly layered on top of Java's built-in support. Those already familiar with the way this support works will find the scheme described here easy to understand. Those not familiar with this support may wish to browse the Java Internationalization page on the Sun Microsystems web site for additional background information.
What is a resource bundle?
A resource bundle is essentially one or more Java "properties" files.
A Java properties file is just a list of "key-value" pairs. There is a "key" associated with every piece of text that needs to appear in the application. The "value" is the string that appears in the application. Thus, when the program needs a string, it accesses it from this file in a standard way using a key and displays whatever value is returned. Note that the program must be specifically written to access strings in this manner. If a Protege plug-in has not been written to be localizable, then you cannot localize it by providing a resource bundle. Instead you need to make modifications to the source code (or talk the original plug-in developer into doing so).
To follow is an example of a properties file (snippet taken from the actual properties file for the main Protege application):
menubar.file=File menubar.file.mnemonic=F menubar.edit=Edit menubar.edit.mnemonic=E menubar.project=Project menubar.project.mnemonic=P menubar.window=Window menubar.window.mnemonic=W menubar.help=Help menubar.help.mnemonic=H project.new=New Project... project.new.mnemonic=N project.new.shortcut=N project.open=Open... project.open.mnemonic=O project.open.shortcut=O project.open_recent=Open Recent project.open_remote=Open Remote Project... project.open_remote.mnemonic=R project.close=Close Project project.close.mnemonic=C project.save=Save Project project.save.mnemonic=S ...
The main Protege application (and each Protege plug-in) must have separate resource bundles for each language. Files in a resource bundle use the naming convention of <something>.properties. The property resource bundles for the main Protege application are located in the Protege installation directory and are named "protege_text_<language>_<country>.properties". Property resource bundles for Protege plug-ins go in the plug-in's installation directory and are named something like "<plugin_name>_text_<language>_<country>.properties". The exact name for the plug-in's files are chosen by the plug-in author.
These properties files contain the strings used by the Protege application. There can be simultaneous English, French, and German versions of these strings available in the same Protege installation since each file will have its own unique name. There can also be variants of these properties files such as "Canadian French", "Swiss French", "Australian English", etc. When the system starts up, the locale of the application is checked and the closest available set of files are loaded. Thus a user in Geneva might start up the application and strings would be loaded first from the "Swiss French", then from the "French", and then from the "default" properties files. This sort of mechanism decreases maintenance problems because the country specific files, if needed at all, can be quite small, only providing "overrides" where default language provides a value that is undesirable for the language dialect spoken in that country.
How do I use an existing resource bundle?
You simply need to place the relevant properties files in the installation directory for the program you are trying to localize. For the main Protege application, this is the Protege installation directory; for a plug-in, it is the plug-in's installation directory. For example, if you wanted to localize the Collaborative Protege extension, you would place the properties file in:
When Protege starts up, it prints the language and country (to the console window) that it believes is appropriate for you based on your system. The language and country are both two letter codes - the language is always lower case and the country is always upper case. These codes are used in identifying the resource bundle that the system will use.
You may wish to use a resource bundle other than the one that is the default for your system. To do this you need to override the language/country that the Java runtime system reports to the application by setting the "user.language" Java property to the two-character code that you desire. You can also specify the country dialect of a language by setting the "user.country" Java property. These properties can be specified in the Protege.lax file or on the Java command line, depending on how you start Protege.
A list of the two-character language codes is available at: http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt
... and a list of the two-character country codes is available at: http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html