public class SpincastDictionaryDefault extends DictionaryBase implements Dictionary
Dictionary.
Provides a value for the core Spincast messages required by any application.
You have to override the addMessages() method to
add your own messages.
| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
| Constructor and Description |
|---|
SpincastDictionaryDefault(LocaleResolver localeResolver,
TemplatingEngine templatingEngine,
SpincastConfig spincastConfig,
Set<DictionaryEntries> dictionaryEntries) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCoreAndPluginsMessages() |
protected void |
addMessages()
To override to add messages to the dictionary.
|
String |
get(String key)
Gets a message.
|
String |
get(String key,
boolean forceTemplatingEngine)
Gets a message.
|
String |
get(String key,
Locale locale)
Gets a message.
|
String |
get(String key,
Locale locale,
boolean forceEvaluation)
Gets a message.
|
String |
get(String key,
Locale locale,
Map<String,Object> params)
Gets a message.
|
String |
get(String key,
Locale locale,
Map<String,Object> params,
Locale originalLocale) |
String |
get(String key,
Locale locale,
Pair... params)
Gets a message.
|
String |
get(String key,
Map<String,Object> params)
Gets a message.
|
String |
get(String key,
Pair... params)
Gets a message.
|
protected Locale |
getDefaultLocale() |
protected Set<DictionaryEntries> |
getDictionaryEntries() |
protected SpincastConfig |
getSpincastConfig() |
protected TemplatingEngine |
getTemplatingEngine() |
protected String |
keyNotFound(String key,
Locale originalLocale,
Map<String,Object> params) |
getMessages, key, msg@Inject public SpincastDictionaryDefault(LocaleResolver localeResolver, TemplatingEngine templatingEngine, SpincastConfig spincastConfig, @Nullable Set<DictionaryEntries> dictionaryEntries)
protected Locale getDefaultLocale()
protected TemplatingEngine getTemplatingEngine()
protected SpincastConfig getSpincastConfig()
protected Set<DictionaryEntries> getDictionaryEntries()
public String get(String key)
LocaleResolver.get in interface Dictionarypublic String get(String key, Locale locale)
DictionaryUses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo() and
SpincastConfig.getDictionaryEntryNotFoundBehavior().
get in interface Dictionarypublic String get(String key, boolean forceTemplatingEngine)
LocaleResolver.get in interface DictionaryforceTemplatingEngine - if true,
the TemplatingEngine will be used even there
are no parameters. This may be useful to trigger some
templating function that don't need parameters. We don't
use the templting engine will default since it is costy.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo() and
SpincastConfig.getDictionaryEntryNotFoundBehavior().
public String get(String key, Locale locale, boolean forceEvaluation)
DictionaryUses the specified Locale.
get in interface DictionaryforceEvaluation - if true,
the TemplatingEngine will be used even there
are no parameters. This may be useful to trigger some
templating function that don't need parameters. We don't
use the templting engine will default since it is costy.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo() and
SpincastConfig.getDictionaryEntryNotFoundBehavior().
public final String get(String key, Pair... params)
LocaleResolver.get in interface Dictionarypublic String get(String key, Locale locale, Pair... params)
DictionaryUses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo() and
SpincastConfig.getDictionaryEntryNotFoundBehavior().
get in interface Dictionarypublic String get(String key, Map<String,Object> params)
LocaleResolver.get in interface Dictionarypublic String get(String key, Locale locale, Map<String,Object> params)
DictionaryUses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo() and
SpincastConfig.getDictionaryEntryNotFoundBehavior().
get in interface Dictionaryprotected String keyNotFound(String key, Locale originalLocale, Map<String,Object> params)
protected void addCoreAndPluginsMessages()
protected void addMessages()
Example :
protected void addMessages() {
super.addMessages();
key("my.message.key",
msg("en", "The message in english"),
msg("fr", "Le message en français"));
}
Copyright © 2019. All rights reserved.