/** * @param key Alternate field name (default to java variable name) * @return The translated message */ public String message(String key) { key = Messages.get(key); Object[] args = new Object[variables.length + 1]; System.arraycopy(variables, 0, args, 1, variables.length); args[0] = key; return Messages.get(message, args); }
public String __getMessage(Object[] val) { if (val == null) { throw new NullPointerException("You are trying to resolve a message with an expression " + "that is resolved to null - " + "have you forgotten quotes around the message-key?"); } if (val.length == 1) { return Messages.get(val[0]); } else { // extract args from val Object[] args = new Object[val.length - 1]; for (int i = 1; i < val.length; i++) { args[i - 1] = val[i]; } return Messages.get(val[0], args); } }
public static String formatString(Locale locale, String value, Object... args) { String message = String.format(locale, value, coolStuff(value, args)); Matcher matcher = recursive.matcher(message); StringBuffer sb = new StringBuffer(); while (matcher.find()) { matcher.appendReplacement(sb, get(matcher.group(1))); } matcher.appendTail(sb); return sb.toString(); }
public void error(String value, Object... args) { put("error", Messages.get(value, args)); }
public void success(String value, Object... args) { put("success", Messages.get(value, args)); }
/** * Returns the form errors serialized as Json using the given Lang. */ public com.fasterxml.jackson.databind.JsonNode errorsAsJson(play.i18n.Lang lang) { Map<String, List<String>> allMessages = new HashMap<String, List<String>>(); for (String key : errors.keySet()) { List<ValidationError> errs = errors.get(key); if (errs != null && !errs.isEmpty()) { List<String> messages = new ArrayList<String>(); for (ValidationError error : errs) { messages.add(play.i18n.Messages.get(lang, error.messages(), error.arguments())); } allMessages.put(key, messages); } } return play.libs.Json.toJson(allMessages); }
/** * Returns the form errors serialized as Json using the given Lang. */ public org.codehaus.jackson.JsonNode errorsAsJson(play.i18n.Lang lang) { Map<String, List<String>> allMessages = new HashMap<String, List<String>>(); for (String key : errors.keySet()) { List<ValidationError> errs = errors.get(key); if (errs != null && !errs.isEmpty()) { List<String> messages = new ArrayList<String>(); for (ValidationError error : errs) { messages.add(play.i18n.Messages.get(lang, error.message(), error.arguments())); } allMessages.put(key, messages); } } return play.libs.Json.toJson(allMessages); }
return Messages.get("since.seconds", delta, pluralize(delta)); return Messages.get("since.minutes", minutes, pluralize(minutes)); return Messages.get("since.hours", hours, pluralize(hours)); return Messages.get("since.days", days, pluralize(days)); return asdate(date.getTime(), Messages.get("since.format")); return Messages.get("since.months", months, pluralize(months)); return Messages.get("since.years", years, pluralize(years));
size = length + " bytes"; error.append(Messages.get(warning, size)); error.append("\u0001"); error.append(size);