@Component
public class UnityMessageSource
extends org.springframework.context.support.ReloadableResourceBundleMessageSource
implements pl.edu.icm.unity.MessageSource
ResourceBundleMessageSource
which
automatically sets the proper locale from the InvocationContext
and allows for an easier invocation using varargs.
It also sets UTF-8 encoding and disables platform's locale fallback.
Another improvement is loading of messages from all classpath resources which are under messages/per-module-id/messages.properties path and from a respective file which is under configured i18n location in the same subdirectory as the per-module-id from classpath.
Modifier and Type | Field and Description |
---|---|
static String |
PROFILE_FAIL_ON_MISSING |
Constructor and Description |
---|
UnityMessageSource(UnityServerConfiguration config,
boolean failOnMissing) |
UnityMessageSource(UnityServerConfiguration config,
org.springframework.core.env.Environment springEnv) |
Modifier and Type | Method and Description |
---|---|
String |
getDefaultLocaleCode() |
Map<String,Locale> |
getEnabledLocales() |
Locale |
getLocale() |
static Locale |
getLocale(Locale fallback) |
String |
getLocaleCode() |
String |
getMessage(String code,
Object... args) |
String |
getMessageNullArg(String code,
Object... args)
If any of the arguments is null, then empty string is returned
|
String |
getMessageUnsafe(String code,
Object... args) |
Map<String,Locale> |
getSupportedLocales() |
String |
getYesNo(boolean value) |
calculateAllFilenames, calculateFilenamesForLocale, clearCache, clearCacheIncludingAncestors, getMergedProperties, getProperties, loadProperties, newProperties, refreshProperties, resolveCode, resolveCodeWithoutArguments, setConcurrentRefresh, setFileEncodings, setPropertiesPersister, setResourceLoader, toString
addBasenames, getBasenameSet, getCacheMillis, getDefaultEncoding, isFallbackToSystemLocale, setBasename, setBasenames, setCacheMillis, setCacheSeconds, setDefaultEncoding, setFallbackToSystemLocale
getCommonMessages, getDefaultMessage, getDefaultMessage, getMessage, getMessage, getMessage, getMessageFromParent, getMessageInternal, getParentMessageSource, isUseCodeAsDefaultMessage, resolveArguments, setCommonMessages, setParentMessageSource, setUseCodeAsDefaultMessage
createMessageFormat, formatMessage, isAlwaysUseMessageFormat, renderDefaultMessage, setAlwaysUseMessageFormat
public static final String PROFILE_FAIL_ON_MISSING
@Autowired public UnityMessageSource(UnityServerConfiguration config, org.springframework.core.env.Environment springEnv) throws IOException
IOException
public UnityMessageSource(UnityServerConfiguration config, boolean failOnMissing) throws IOException
IOException
public String getMessageNullArg(String code, Object... args)
code
- args
- public String getYesNo(boolean value)
public Locale getLocale()
public String getDefaultLocaleCode()
public String getLocaleCode()
Copyright © 2018 Unity. All rights reserved.