Class LocalizationMessageSource

  • All Implemented Interfaces:
    org.springframework.context.HierarchicalMessageSource, org.springframework.context.MessageSource

    public class LocalizationMessageSource
    extends org.springframework.context.support.AbstractMessageSource
    The standard Molgenis MessageSource which looks up messages in the MessageResolution and delegates MessageFormat creation to a MessageFormatFactory.

    Marks missing values with # characters.

    Caching should be done by the MessageResolution.

    • Method Detail

      • getDefaultMessage

        public String getDefaultMessage​(String code)
        The default message adds # marks around the code so that they stand out as not yet translated.
        Overrides:
        getDefaultMessage in class org.springframework.context.support.AbstractMessageSource
        Parameters:
        code - the untranslated code
        Returns:
        the code surrounded by `#` characters.
      • resolveCode

        public MessageFormat resolveCode​(String code,
                                         Locale locale)
        Looks up the MessageFormat for a code.
        Specified by:
        resolveCode in class org.springframework.context.support.AbstractMessageSource
        Parameters:
        code - the code to look up
        locale - the Locale for which the code should be looked up
        Returns:
        newly created MessageFormat
      • createMessageFormat

        protected MessageFormat createMessageFormat​(String msg,
                                                    Locale locale)
        Overrides:
        createMessageFormat in class org.springframework.context.support.MessageSourceSupport
      • resolveCodeWithoutArguments

        protected String resolveCodeWithoutArguments​(String code,
                                                     @Nullable @CheckForNull
                                                     Locale locale)
        Looks up a code in the MessageResolution.

        First tries the given locale if it is nonnull, then the fallbackLocale and finally the default locale.

        Overrides:
        resolveCodeWithoutArguments in class org.springframework.context.support.AbstractMessageSource
        Parameters:
        code - the messageID to look up.
        locale - the Locale whose language code should be tried first, may be null
        Returns:
        The message, or null if none found.