public interface Messages
Modifier and Type | Method and Description |
---|---|
com.google.common.base.Optional<java.lang.String> |
get(java.lang.String key,
Context context,
com.google.common.base.Optional<Result> result,
java.lang.Object... parameter)
Get a translated string.
|
com.google.common.base.Optional<java.lang.String> |
get(java.lang.String key,
com.google.common.base.Optional<java.lang.String> language,
java.lang.Object... parameter)
Get a translated string.
|
java.util.Map<java.lang.Object,java.lang.Object> |
getAll(Context context,
com.google.common.base.Optional<Result> result)
Returns all messages for the default language in that context / result.
|
java.util.Map<java.lang.Object,java.lang.Object> |
getAll(com.google.common.base.Optional<java.lang.String> language)
Deprecated.
Might be removed from further releases. Usually is not implemented in a thread
safe way and is error prone.
Returns all messages for a language we have. Please note that this method
does NOT format any MessageFormat values. You have to do that yourself in
the controller logic most likely.
Note: If you don't want to determine the language yourself please use
Messages#getAll(Context, Result) |
java.lang.String |
getWithDefault(java.lang.String key,
java.lang.String defaultMessage,
Context context,
com.google.common.base.Optional<Result> result,
java.lang.Object... params)
Gets a message for a message key.
|
java.lang.String |
getWithDefault(java.lang.String key,
java.lang.String defaultMessage,
com.google.common.base.Optional<java.lang.String> language,
java.lang.Object... params)
Gets a message for a message key.
|
com.google.common.base.Optional<java.lang.String> get(java.lang.String key, com.google.common.base.Optional<java.lang.String> language, java.lang.Object... parameter)
Messages#get(String, Context, Result, Object...)
key
- The key used in your message file (conf/messages.properties)language
- The language to get. Can be null - then the default language
is returned. It also looks for a fallback. Eg. A request for
"en-US" will fallback to "en" if there is no matching language
file.parameter
- Parameters to use in formatting the message of the key (in
MessageFormat
).com.google.common.base.Optional<java.lang.String> get(java.lang.String key, Context context, com.google.common.base.Optional<Result> result, java.lang.Object... parameter)
key
- The key used in your message file (conf/messages.properties)context
- The context used to determine the language.result
- The result used to determine the language.parameter
- Parameters to use in formatting the message of the key (in
MessageFormat
).java.lang.String getWithDefault(java.lang.String key, java.lang.String defaultMessage, com.google.common.base.Optional<java.lang.String> language, java.lang.Object... params)
Messages#getWithDefault(String, Context, Result, Object...)
key
- The key used in your message file (conf/messages.properties)defaultMessage
- A default message that will be used when no matching message
can be retrieved.language
- The language to get. May be absent - then the default language
is returned. It also looks for a fallback. Eg. A request for
"en-US" will fallback to "en" if there is no matching language
file.parameter
- Parameters to use in formatting the message of the key (in
MessageFormat
).java.lang.String getWithDefault(java.lang.String key, java.lang.String defaultMessage, Context context, com.google.common.base.Optional<Result> result, java.lang.Object... params)
key
- The key used in your message file (conf/messages.properties)defaultMessage
- A default message that will be used when no matching message
can be retrieved.context
- The context used to determine the language.result
- The result used to determine the language. May be absentparams
- Parameters to use in formatting the message of the key (in
MessageFormat
).@Deprecated java.util.Map<java.lang.Object,java.lang.Object> getAll(com.google.common.base.Optional<java.lang.String> language)
Messages#getAll(Context, Result)
language
- The language to get. May be absent - then the default language
is returned. It also looks for a fallback. Eg. A request for
"en-US" will fallback to "en" if there is no matching language
file.
language can also be the complete Accept-Language header: en-US,en;q=0.8,de;q=0.6java.util.Map<java.lang.Object,java.lang.Object> getAll(Context context, com.google.common.base.Optional<Result> result)
context
- The contextresult
- The result - bay be absentCopyright © 2016 ninjaframework. All Rights Reserved.