
public.javadoc.org.spincast.plugins.dictionary.SpincastDictionaryDefault.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
SpincastDictionaryDefault (org.spincast:spincast-framework 1.14.0 API)
org.spincast.plugins.dictionary
Class SpincastDictionaryDefault
- java.lang.Object
-
- org.spincast.core.dictionary.DictionaryBase
-
- org.spincast.plugins.dictionary.SpincastDictionaryDefault
-
- All Implemented Interfaces:
- Dictionary
public class SpincastDictionaryDefault
extends DictionaryBase
implements Dictionary
Default implementation of the 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.
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
SpincastDictionaryDefault(LocaleResolver localeResolver,
TemplatingEngine templatingEngine,
SpincastConfig spincastConfig,
Set<DictionaryEntries> dictionaryEntries)
-
Method Summary
All Methods Instance Methods Concrete Methods
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)
-
Methods inherited from class org.spincast.core.dictionary.DictionaryBase
getMessages, key, msg
-
-
Constructor Detail
-
SpincastDictionaryDefault
@Inject
public SpincastDictionaryDefault(LocaleResolver localeResolver,
TemplatingEngine templatingEngine,
SpincastConfig spincastConfig,
@Nullable
Set<DictionaryEntries> dictionaryEntries)
-
Method Detail
-
getDefaultLocale
protected Locale getDefaultLocale()
-
getTemplatingEngine
protected TemplatingEngine getTemplatingEngine()
-
getSpincastConfig
protected SpincastConfig getSpincastConfig()
-
getDictionaryEntries
protected Set<DictionaryEntries> getDictionaryEntries()
-
get
public String get(String key)
Gets a message.
Will use the proper Locale as provided by the
LocaleResolver
.
- Specified by:
get
in interface Dictionary
-
get
public String get(String key,
Locale locale)
Description copied from interface: Dictionary
Gets a message.
Uses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo()
and
SpincastConfig.getDictionaryEntryNotFoundBehavior()
.
- Specified by:
get
in interface Dictionary
-
get
public String get(String key,
boolean forceTemplatingEngine)
Gets a message.
Will use the proper Locale as provided by the
LocaleResolver
.
- Specified by:
get
in interface Dictionary
forceTemplatingEngine
- 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()
.
-
get
public String get(String key,
Locale locale,
boolean forceEvaluation)
Description copied from interface: Dictionary
Gets a message.
Uses the specified Locale.
- Specified by:
get
in interface Dictionary
forceEvaluation
- 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()
.
-
get
public final String get(String key,
Pair... params)
Gets a message.
Will use the proper Locale as provided by the
LocaleResolver
.
- Specified by:
get
in interface Dictionary
-
get
public String get(String key,
Locale locale,
Pair... params)
Description copied from interface: Dictionary
Gets a message.
Uses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo()
and
SpincastConfig.getDictionaryEntryNotFoundBehavior()
.
- Specified by:
get
in interface Dictionary
-
get
public String get(String key,
Map<String,Object> params)
Gets a message.
Will use the proper Locale as provided by the
LocaleResolver
.
- Specified by:
get
in interface Dictionary
-
get
public String get(String key,
Locale locale,
Map<String,Object> params)
Description copied from interface: Dictionary
Gets a message.
Uses the specified Locale.
The behavior if the key is not found can be configured using
SpincastConfig#getDictionaryEntryNotFoundFallbackTo()
and
SpincastConfig.getDictionaryEntryNotFoundBehavior()
.
- Specified by:
get
in interface Dictionary
-
keyNotFound
protected String keyNotFound(String key,
Locale originalLocale,
Map<String,Object> params)
-
addCoreAndPluginsMessages
protected void addCoreAndPluginsMessages()
-
addMessages
protected void addMessages()
To override to add messages to the dictionary.
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.