Localizing Frameworks

Oxygen XML Editor plugin supports framework localization (translating framework actions, buttons, and menu entries to different languages). Thus you can develop and distribute a framework to users that speak different languages without changing the distributed framework. Changing the language used in Oxygen (in Options > Preferences > Global > Language Global preferences page) is enough to set the right language for each framework.

To localize the content of a framework, create a translation.xml file which contains all the translation (key, value) mappings. The translation.xml has the following format:

<translation>
    <languageList>
        <language description="English" lang="en_US"/>
        <language description="German" lang="de_DE"/>
        <language description="French" lang="fr_FR"/>
    </languageList>
    <key value="list">
        <comment>List menu item name.</comment>
        <val lang="en_US">List</val>
        <val lang="de_DE">Liste</val>
        <val lang="fr_FR">Liste</val>
    </key>  
......................
</translation> 

Oxygen XML Editor plugin matches the GUI language with the language set in the translation.xml file. In case this language is not found, the first available language declared in the languagelist tag for the corresponding framework is used.

Add the directory where this file is located to the Classpath list corresponding to the edited document type.

After you create this file, you are able to use the keys defined in it to customize the name and description of:

For example, if you want to localize the bold action go to Options > Preferences > Document Type Association. Open the Document type dialog, go to Author > Actions, and rename the bold action to ${i18n(translation_key)}. Actions with a name format different than ${i18n(translation_key)} are not localized. Translation_key corresponds to the key from the translation.xml file.

Now open the translation.xml file and edit the translation entry if it exists or create one if it does not exist. This example presents an entry in the translation.xml file:

<key value="translation_key">
        <comment>Bold action name.</comment>
        <val lang="en_US">Bold</val>
        <val lang="de_DE">Bold</val>
        <val lang="fr_FR">Bold</val>
    </key>

To use a description from the translation.xml file in the Java code used by your custom framework, use the new ro.sync.ecss.extensions.api.AuthorAccess.getAuthorResourceBundle() API method to request for a certain key the associated value. In this way all the dialogs that you present from your custom operations can have labels translated in different languages.

Note: You can enter any language you want in the languagelist tag and any number of keys.

The translation.xml file for the DocBook framework is located here:[OXYGEN_INSTALL_DIR]/frameworks/docbook/i18n/translation.xml. In the Classpath list corresponding to the Docbook document type the following entry was added: ${framework}/i18n/.

In Options > Preferences > Document Type Association > Author > Actions, you can see how the DocBook actions are defined to use these keys for their name and description. If you look in the Java class ro.sync.ecss.extensions.docbook.table.SADocbookTableCustomizerDialog available in the Author SDK, you can see how the new ro.sync.ecss.extensions.api.AuthorResourceBundle API is used to retrieve localized descriptions for different keys.