public class Messages extends Object
translation are defined as properties in /conf/messages.locale files with locale being the i18n country code fr, en, fr_FR
# /conf/messages.fr hello=Bonjour, %s !
Messages.get( "hello", "World"); // => "Bonjour, World !"
| Modifier and Type | Field and Description |
|---|---|
static Properties |
defaults |
static Map<String,Properties> |
locales |
| Constructor and Description |
|---|
Messages() |
| Modifier and Type | Method and Description |
|---|---|
static Properties |
all(String locale)
return all messages for a locale
|
static Properties |
find(String locale,
Set<String> keys)
Return several messages for a locale
|
static String |
formatString(Locale locale,
String value,
Object... args) |
static String |
formatString(String value,
Object... args) |
static String |
get(Object key,
Object... args)
Given a message code, translate it using current locale.
|
static String |
getMessage(String locale,
Object key,
Object... args) |
public static Properties defaults
public static Map<String,Properties> locales
public static String get(Object key, Object... args)
key - the message codeargs - optional message format argumentspublic static Properties find(String locale, Set<String> keys)
locale - the locale code, e.g. fr, fr_FRkeys - the keys to get messages from. Wildcards can be used at the end: {'title', 'login.*'}java.util.Propertiespublic static Properties all(String locale)
locale - the locale code eg. fr, fr_FRjava.util.PropertiesGuillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly