Class AbstractUiLocalizer

    • Constructor Detail

      • AbstractUiLocalizer

        public AbstractUiLocalizer()
        The constructor.
    • Method Detail

      • setLocale

        public void setLocale​(Locale locale)
        Parameters:
        locale - new value of getLocale().
      • localizeOrNull

        public String localizeOrNull​(String key,
                                     Object context,
                                     boolean contextOnly)
        Specified by:
        localizeOrNull in interface UiLocalizer
        Parameters:
        key - the key.
        context - the optional context of the key to localize. If not null it can identify a more specific ResourceBundle. This allows to define a default localization for a general key but gives the localizer the ability to override this default with a specialized localization in that context. As an example we assume that key is "head". Now if the context is "HTML" or "Human" the ambiguous meaning of the key can be resolved and more appropriate localizations can be chosen. A common case is to localize properties of beans. Here the bean is provided as context so you have the freedom to choose a specific localization for a general property key such as "name" depending on the bean that defines the property without changing the actual UI code. Finally, the context may be a variant such as UiLocalizer.KEY_TOOLTIP to derive a localized message for a different purpose.
        contextOnly - - true to return null in case no context specific localization is available and omit further fallback, false otherwise. When true is provided here, the context should not be null or this method will simply return null.
        Returns:
        the localized text. Will be null if no localization is available.