/** * @return the default locale if the Locale cannot be found otherwise the locale * associated to the current Lang. */ public static Locale getLocale() { return getLocaleOrDefault(get()); }
public void set(T value) { this.values.put(Lang.get(), value); }
public static Tuple getLocale(String[] langs) { int i = 0; for (String l : langs) { String[] commaSeparatedLang = l.split(","); for (String lang : commaSeparatedLang) { if (Lang.get().equals(lang) || "*".equals(lang)) { Locale locale = null; if ("*".equals(lang)) { locale = Lang.getLocale(); } if (locale == null) { locale = Lang.getLocale(lang); } if (locale != null) { return new Tuple(i, locale); } } } i++; } return null; }
public T get() { return this.values.get(Lang.get()); }
public static String getDateFormat() { String localizedDateFormat = Play.configuration.getProperty("date.format." + Lang.get()); if (!StringUtils.isEmpty(localizedDateFormat)) { return localizedDateFormat; } String globalDateFormat = Play.configuration.getProperty("date.format"); if (!StringUtils.isEmpty(globalDateFormat)) { return globalDateFormat; } // Default value. It's completely arbitrary. return "yyyy-MM-dd"; }
/** * Given a message code, translate it using current locale. If there is no message in the current locale for the * given key, the key is returned. * * @param key * the message code * @param args * optional message format arguments * @return translated message */ public static String get(Object key, Object... args) { return getMessage(Lang.get(), key, args); }
public static String format(Date date, String pattern) { return format(date, pattern, Lang.get()); }
public static String asdate(Long timestamp, String pattern) { return asdate(timestamp, pattern, Lang.get()); }
protected Binding setUpBindingVariables(Map<String, Object> args) { Binding binding = new Binding(args); binding.setVariable("play", new Play()); binding.setVariable("messages", new Messages()); binding.setVariable("lang", Lang.get()); return binding; }