Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Eclipse4/RCP/Modeled UI/Localization

< Eclipse4‎ | RCP‎ | Modeled UI

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.
  • Place your translated strings in property files with a common prefix and suffixed by _LL.properties where LL is the locale.
  • By default these translation files are expected to be found in OSGI-INF/l10n/ with prefix bundle (i.e., OSGI-INF/l10n/bundle_en.properties). If you wish to store them elsewhere within your bundle and/or use a different prefix, then set the Bundle-Localization header. 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.

Back to the top