Localization of Model Elements
Many model elements support providing localized text. For example, MUILabel elements can provide localized labels and tooltips; MCommand can provide localized command names and descriptions. These keyes are translated using the E4AP's TranslationService. The translation service is obtained from the element's context as an instance of "org.eclipse.e4.core.services.translation.TranslationService".
The default translation service provided by the E4AP uses the OSGi bundle translation service. In a nutshell, to use this service:
- Ensure the contributorURI attribute on modelled elements is set to to the bundle hosting the translations (e.g., platform:/plugin/XXX where XXX is the symbolic name of the hosting bundle). If your elements were defined in an .e4xmi file then the contributorURI is automatically set to the bundle hosting the .e4xmi file.
- Translated strings are key-value pairs. In the model element definitions, the translated strings are referred to by the key prefixed with a "%"; untranslated strings starting with a percent can be escaped by using a doubled-percent.
- The bundle hosting the translations should set the Bundle-Localization header in its manifest to the prefix of the translation files. These files are typically found at the root of the bundle; you'll also see some uses of OSGI-INF/l10n/ or OSGI-INF/i18n/. For example, most Eclipse-provided plugins use "Bundle-Localization: plugin" and the translations are found in files plugin.properties and plugin_XX.properties where XX is the language prefix.