/** * Constructs a MessagesApi instance containing the given keys and values. * * @return a messagesApi instance containing given keys and values. */ public static MessagesApi stubMessagesApi(Map<String, Map<String, String>> messages, play.i18n.Langs langs) { return new play.i18n.MessagesApi( new play.api.i18n.DefaultMessagesApi(messages, langs) ); }
/** * Translates a message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public static String get(String key, Object... args) { return getMessagesApi().get(getLang(), key, args); }
/** * Check if a message key is defined. * @param lang the message lang * @param key the message key * @return a Boolean */ public static Boolean isDefined(Lang lang, String key) { return getMessagesApi().isDefinedAt(lang, key); }
/** * Get the message at the given key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String at(String key, Object... args) { return messages.get(lang, key, args); }
/** * Get the message at the given key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ default String apply(String key, Object... args) { return at(key, args); }
/** * Translates a message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param lang the message lang * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public static String get(Lang lang, String key, Object... args) { return getMessagesApi().get(lang, key, args); }
/** * Check if a message key is defined. * @param key the message key * @return a Boolean */ public static Boolean isDefined(String key) { return getMessagesApi().isDefinedAt(getLang(), key); }
/** * Check if a message key is defined. * * @param key the message key * @return a Boolean */ public Boolean isDefinedAt(String key) { return messagesApi.isDefinedAt(lang, key); }
/** * Convert to a Java Locale value. */ public java.util.Locale toLocale() { return locale(); }
/** * Get the message at the given key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String at(String key, Object... args) { return messagesApi.get(lang, key, args); }
/** * Translates the first defined message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param keys the messages keys * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public static String get(List<String> keys, Object... args) { return getMessagesApi().get(getLang(), keys, args); }
/** * Get the message at the first defined key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param keys the messages keys * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ default String apply(List<String> keys, Object... args) { return at(keys, args); }
/** * Translates the first defined message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param lang the message lang * @param keys the messages keys * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public static String get(Lang lang, List<String> keys, Object... args) { return getMessagesApi().get(lang, keys, args); }
/** * Check if a message key is defined. * * @param key the message key * @return a Boolean */ public Boolean isDefinedAt(String key) { return messagesApi.isDefinedAt(lang, key); }
/** * Constructs a MessagesApi instance containing the given keys and values. * * @return a messagesApi instance containing given keys and values. */ public static MessagesApi stubMessagesApi(Map<String, Map<String, String>> messages, play.i18n.Langs langs) { return new play.i18n.MessagesApi( new play.api.i18n.DefaultMessagesApi(messages, langs) ); }
/** * Get the message at the first defined key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param keys the messages keys * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String at(List<String> keys, Object... args) { return messagesApi.get(lang, keys, args); }
/** * Get the message at the given key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ default String apply(String key, Object... args) { return at(key, args); }
/** * Constructs an empty messagesApi instance. * * @return a messagesApi instance containing no values. */ public static MessagesApi stubMessagesApi() { return new play.i18n.MessagesApi(new play.api.i18n.DefaultMessagesApi (Collections.emptyMap(), new DefaultLangs().asJava())); }
/** * Get the message at the first defined key. * * Uses `java.text.MessageFormat` internally to format the message. * * @param keys the messages keys * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String at(List<String> keys, Object... args) { return messagesApi.get(lang, keys, args); }
/** * Constructs an empty messagesApi instance. * * @return a messagesApi instance containing no values. */ public static MessagesApi stubMessagesApi() { return new play.i18n.MessagesApi(new play.api.i18n.DefaultMessagesApi (Collections.emptyMap(), new DefaultLangs().asJava())); }