/** * 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 */ public String at(String key, Object... args) { return messagesApi.get(lang, key, 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 */ public String at(List<String> keys, Object... args) { return messagesApi.get(lang, 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 */ 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 */ public String at(String key, Object... args) { return messagesApi.get(lang, key, 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 */ public String at(List<String> keys, Object... args) { return messages.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 */ public String at(String key, Object... args) { return messagesApi.get(lang, key, 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 */ public String at(List<String> keys, Object... args) { return messagesApi.get(lang, keys, 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); }
/** * 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); }
/** * 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); }
/** * 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); }
private Object translateMsgArg(List<Object> arguments, MessagesApi messagesApi, Lang lang) { if (arguments != null) { return arguments.stream().map(arg -> { if (arg instanceof String) { return messagesApi != null ? messagesApi.get(lang, (String)arg) : (String)arg; } if (arg instanceof List) { return ((List<?>) arg).stream().map(key -> messagesApi != null ? messagesApi.get(lang, (String)key) : (String)key).collect(Collectors.toList()); } return arg; }).collect(Collectors.toList()); } else { return null; } }
private Object translateMsgArg(List<Object> arguments, MessagesApi messagesApi, Lang lang) { if (arguments != null) { return arguments.stream().map(arg -> { if (arg instanceof String) { return messagesApi != null ? messagesApi.get(lang, (String)arg) : (String)arg; } if (arg instanceof List) { return ((List<?>) arg).stream().map(key -> messagesApi != null ? messagesApi.get(lang, (String)key) : (String)key).collect(Collectors.toList()); } return arg; }).collect(Collectors.toList()); } else { return null; } }
private Object translateMsgArg(List<Object> arguments, MessagesApi messagesApi, Lang lang) { if (arguments != null) { return arguments.stream().map(arg -> { if (arg instanceof String) { return messagesApi != null ? messagesApi.get(lang, (String)arg) : (String)arg; } if (arg instanceof List) { return ((List<?>) arg).stream().map(key -> messagesApi != null ? messagesApi.get(lang, (String)key) : (String)key).collect(Collectors.toList()); } return arg; }).collect(Collectors.toList()); } else { return null; } }
/** * Unbinds this fields - converts a concrete value to a plain string. * * @param value the value to unbind * @param locale the current <code>Locale</code> * @return printable version of the value */ public String print(Date value, Locale locale) { if(value == null) { return ""; } Lang lang = new Lang(locale); return new SimpleDateFormat(Optional.ofNullable(this.messagesApi) .map(messages -> messages.get(lang, pattern)) .orElse(patternNoApp), locale).format(value); }
/** * Unbinds this fields - converts a concrete value to a plain string. * * @param value the value to unbind * @param locale the current <code>Locale</code> * @return printable version of the value */ public String print(Date value, Locale locale) { if(value == null) { return ""; } Lang lang = new Lang(locale); return new SimpleDateFormat(Optional.ofNullable(this.messagesApi) .map(messages -> messages.get(lang, pattern)) .orElse(patternNoApp), locale).format(value); }
/** * Unbinds this fields - converts a concrete value to a plain string. * * @param value the value to unbind * @param locale the current <code>Locale</code> * @return printable version of the value */ public String print(Date value, Locale locale) { if(value == null) { return ""; } Lang lang = new Lang(locale); return new SimpleDateFormat(Optional.ofNullable(this.messagesApi) .map(messages -> messages.get(lang, pattern)) .orElse(patternNoApp), locale).format(value); }
/** * Unbinds this field - converts a concrete value to plain string * * @param annotation the annotation that triggered this formatter * @param value the value to unbind * @param locale the current <code>Locale</code> * @return printable version of the value */ public String print(DateTime annotation, Date value, Locale locale) { if(value == null) { return ""; } Lang lang = new Lang(locale); return new SimpleDateFormat(Optional.ofNullable(this.messagesApi) .map(messages -> messages.get(lang, annotation.pattern())) .orElse(annotation.pattern()), locale).format(value); }
/** * Unbinds this field - converts a concrete value to plain string * * @param annotation the annotation that triggered this formatter * @param value the value to unbind * @param locale the current <code>Locale</code> * @return printable version of the value */ public String print(DateTime annotation, Date value, Locale locale) { if(value == null) { return ""; } Lang lang = new Lang(locale); return new SimpleDateFormat(Optional.ofNullable(this.messagesApi) .map(messages -> messages.get(lang, annotation.pattern())) .orElse(annotation.pattern()), locale).format(value); }