20. translation

<translation
  location = anyURI matching [path/]resourcename_lang.properties
/>

Specifies how to translate messages found in action label and toolTip, pane label, layout label, etc.

Localizing GUI specification files works as follows:

  1. The location attribute points to a Java™ property file. Example used in the tutorial:

    <translation location="custom_gui_en.properties" />
        ...
    <layout label="Document Editor" icon="docedit.png">
        ...

    Where custom_gui_en.properties contains:

    layout.label=Document Editor
        ...

    The location URL specifies:

    • The reference language of the GUI specification file: a two-letter lower-case ISO code. In the above example: en.

    • A unique resource name used to find translations to other languages. In the above example: custom_gui. More on this below.

    The reference property file is only used to map messages to message IDs. For example, custom_gui_en.properties specifies that message "Document Editor" has ID "layout.label".

  2. If, for example, XXE is started using a French locale, a property file called custom_gui_fr.properties:

    • is searched in the same directory as the reference property file;

    • OR, if this file is not found there, this property file is searched as a resource using the CLASSPATH. That is, custom_gui_fr.properties is supposed to be contained[5] in a jar file found in the CLASSPATH.

    For performance reasons, language variants such CA in fr-CA are not supported.

  3. For the localization to work, the translated property file must refer to the same IDs as those found in the reference property file.

    For example, custom_gui_fr.properties contains:

    layout.label=Éditeur de Document
         ...


[5] Directly contained, and not contained in a ``folder''. That is, "jar tvf foo.jar" must display custom_gui_fr.properties and not foo/bar/custom_gui_fr.properties.