Interface LocalizationManager


  • @Role
    public interface LocalizationManager
    Internationalization service based on key/property values. The key is the id of the message being looked for, and the returned value is the message in the specified language.

    Properties are looked for in several bundles, in the order of their priority. The first translation found in one of these bundles is the one returned. If the property is not found in any of these sources, then null is returned.

    Since:
    4.3M2
    Version:
    $Id: c74d10b13de04edcd32bdc35d8b9b336e38241d1 $
    • Method Detail

      • getTranslation

        Translation getTranslation​(String key,
                                   Locale locale)
        Find a translation in the specified locale.
        Parameters:
        key - the key identifying the message to look for
        locale - the Locale for which this translation is searched. The result might me associated to a different Locale (for example getting the fr translation when asking for the fr_FR one).
        Returns:
        the translation in the defined language
        See Also:
        LocalizationManager
      • getTranslationPlain

        default String getTranslationPlain​(String key,
                                           Locale locale,
                                           Object... parameters)
        Find a translation in the current language.
        Parameters:
        key - the key identifying the message to look for
        locale - the Locale for which this translation is searched. The result might me associated to a different Locale (for example getting the fr translation when asking for the fr_FR one).
        parameters - the parameters
        Returns:
        the translation in the current language rendered as plain text, null if no translation could be found
        Since:
        14.1RC1, 13.10.3
        See Also:
        getTranslation(String, Locale)
      • use

        void use​(String bundleType,
                 String bundleId)
          throws TranslationBundleDoesNotExistsException,
                 TranslationBundleFactoryDoesNotExistsException
        Registers a resource location as a possible localization bundle that should be used in the current execution. The order in which resource of the same type are considered when searching for a translation corresponds to the order in which they were pulled. Each execution (generally a client request) has its own list of pulled resources, and at the end of an execution, its list of pulled resources is cleared.
        Parameters:
        bundleType - a hint identifying the bundle type.
        bundleId - the identifier of the bindle, for example a wiki document name, or the URL to a .properties file.
        Throws:
        TranslationBundleDoesNotExistsException - when no bundle could be found for the passed identifier
        TranslationBundleFactoryDoesNotExistsException - when no bundle factory could be found for the passed type
      • getDefaultLocale

        default Locale getDefaultLocale()
        Returns:
        the Locale configured as the default
        Since:
        14.1RC1, 13.10.3