Interface TranslationProvider


@NonNullByDefault public interface TranslationProvider
The TranslationProvider is a service interface for internationalization support within the platform. This service can be used to translate specific keys into its according text by considering the specified Locale (language). Any module which supports resource files is managed by this provider and used for translation. This service uses the i18n mechanism of Java.
Author:
Michael Grammling - Initial contribution, Thomas Höfer - Added getText operation with arguments
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable String
    getText(@Nullable org.osgi.framework.Bundle bundle, @Nullable String key, @Nullable String defaultText, @Nullable Locale locale)
    Returns a translation for the specified key in the specified locale (language) by only considering the translations within the specified module.
    @Nullable String
    getText(@Nullable org.osgi.framework.Bundle bundle, @Nullable String key, @Nullable String defaultText, @Nullable Locale locale, @Nullable Object @Nullable ... arguments)
    Returns a translation for the specified key in the specified locale (language) by only considering the translations within the specified module.
  • Method Details

    • getText

      @Nullable String getText(@Nullable org.osgi.framework.Bundle bundle, @Nullable String key, @Nullable String defaultText, @Nullable Locale locale)
      Returns a translation for the specified key in the specified locale (language) by only considering the translations within the specified module.

      If no translation could be found, the specified default text is returned.
      If the specified locale is null, the default locale is used.

      Parameters:
      bundle - the module to be used for the look-up (could be null)
      key - the key to be translated (could be null or empty)
      defaultText - the default text to be used (could be null or empty)
      locale - the locale (language) to be used (could be null)
      Returns:
      the translated text or the default text (could be null or empty)
    • getText

      @Nullable String getText(@Nullable org.osgi.framework.Bundle bundle, @Nullable String key, @Nullable String defaultText, @Nullable Locale locale, @Nullable Object @Nullable ... arguments)
      Returns a translation for the specified key in the specified locale (language) by only considering the translations within the specified module. The operation will inject the given arguments into the translation.

      If no translation could be found, the specified default text is returned.
      If the specified locale is null, the default locale is used.

      Parameters:
      bundle - the module to be used for the look-up (could be null)
      key - the key to be translated (could be null or empty)
      defaultText - the default text to be used (could be null or empty)
      locale - the locale (language) to be used (could be null)
      arguments - the arguments to be injected into the translation (could be null)
      Returns:
      the translated text or the default text (could be null or empty)