Class TranslationService

java.lang.Object
org.eclipse.e4.core.services.translation.TranslationService

public abstract class TranslationService extends Object
Provides localization service.
Since:
1.2
  • Field Details

    • LOCALE

      public static final String LOCALE
      The name of the context variable with locale information
      See Also:
    • locale

      @Inject @Named("org.eclipse.e4.core.locale") protected Locale locale
  • Constructor Details

    • TranslationService

      public TranslationService()
  • Method Details

    • translate

      public String translate(String key, String contributorURI)
      Translates the key from the contributor. If translation can not be found, the original key should be returned.

      This method is expected to be overridden by the implementors.

      Parameters:
      key - the key
      contributorURI - URI of the contributor
      Returns:
      localized value, or the original key if the translation can not be done
    • getResourceString

      protected String getResourceString(String key, ResourceBundle resourceBundle)
      Returns the value out of the given ResourceBundle for the given translation key. Note that this method will only work correctly if the key matches the specification of a translation key in the application model. That means, it needs to start with a % character.
      Parameters:
      key - The value that is set as key in the application model.
      resourceBundle - The ResourceBundle that should be used to retrieve the translation.
      Returns:
      The value value out of the given ResourceBundle for the given translation key.