public class LocalizationMessageSource
extends org.springframework.context.support.AbstractMessageSource
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.
| Constructor and Description |
|---|
LocalizationMessageSource(MessageFormatFactory messageFormatFactory,
MessageResolution messageRepository,
Supplier<Locale> fallbackLocaleSupplier) |
| Modifier and Type | Method and Description |
|---|---|
protected MessageFormat |
createMessageFormat(String msg,
Locale locale) |
String |
getDefaultMessage(String code)
The default message adds # marks around the code so that they stand out as not yet translated.
|
MessageFormat |
resolveCode(String code,
Locale locale)
Looks up the
MessageFormat for a code. |
protected String |
resolveCodeWithoutArguments(String code,
Locale locale)
Looks up a code in the
MessageResolution. |
getCommonMessages, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessagepublic LocalizationMessageSource(MessageFormatFactory messageFormatFactory, MessageResolution messageRepository, Supplier<Locale> fallbackLocaleSupplier)
public String getDefaultMessage(String code)
getDefaultMessage in class org.springframework.context.support.AbstractMessageSourcecode - the untranslated codepublic MessageFormat resolveCode(String code, Locale locale)
MessageFormat for a code.resolveCode in class org.springframework.context.support.AbstractMessageSourcecode - the code to look uplocale - the Locale for which the code should be looked upMessageFormatprotected MessageFormat createMessageFormat(String msg, Locale locale)
createMessageFormat in class org.springframework.context.support.MessageSourceSupportprotected String resolveCodeWithoutArguments(String code, @Nullable Locale locale)
MessageResolution.
First tries the given locale if it is nonnull, then the fallbackLocale and finally the default locale.
resolveCodeWithoutArguments in class org.springframework.context.support.AbstractMessageSourcecode - the messageID to look up.locale - the Locale whose language code should be tried first, may be nullCopyright © 2018 Pivotal Software, Inc.. All rights reserved.