本文整理匯總了Java中play.i18n.Lang.getLocale方法的典型用法代碼示例。如果您正苦於以下問題:Java Lang.getLocale方法的具體用法?Java Lang.getLocale怎麽用?Java Lang.getLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類play.i18n.Lang
的用法示例。
在下文中一共展示了Lang.getLocale方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLocale
import play.i18n.Lang; //導入方法依賴的package包/類
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;
}
示例2: sendTestMail
import play.i18n.Lang; //導入方法依賴的package包/類
public void sendTestMail() throws Exception {
if (Loggers.Auth.isDebugEnabled()) {
Loggers.Auth.debug("Send test mail " + toString());
}
InternetAddress email_addr = getInternetAddress();
if (email_addr == null) {
return;
}
EndUserBaseMail mail;
if (language == null) {
mail = new EndUserBaseMail(Locale.getDefault(), "usertestmail", email_addr);
} else {
mail = new EndUserBaseMail(Lang.getLocale(language), "usertestmail", email_addr);
}
mail.send();
}
示例3: getDateAs
import play.i18n.Lang; //導入方法依賴的package包/類
/**
* It can be something like As(lang={"fr,de","*"}, value={"dd-MM-yyyy","MM-dd-yyyy"})
*
* @param annotations
* @param value
* @return null if it cannot be converted because there is no annotation.
* @throws ParseException
*
*/
public static Date getDateAs(Annotation[] annotations, String value) throws ParseException {
// Look up for the BindAs annotation
if (annotations == null) {
return null;
}
for (Annotation annotation : annotations) {
if (annotation.annotationType().equals(As.class)) {
As as = (As) annotation;
Locale locale = Lang.getLocale();
String format = as.value()[0];
if (!StringUtils.isEmpty(format)) {
// This can be comma separated
Tuple tuple = getLocale(as.lang());
if (tuple != null) {
// Avoid NPE and get the last value if not specified
format = as.value()[tuple.index < as.value().length ? tuple.index : as.value().length - 1];
locale = tuple.locale;
}
}
if (StringUtils.isEmpty(format)) {
format = I18N.getDateFormat();
}
SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
sdf.setLenient(false);
return sdf.parse(value);
}
}
return null;
}
示例4: call
import play.i18n.Lang; //導入方法依賴的package包/類
public Void call() throws Exception {
if (user.getEmailAddr() == null) {
return null;
}
if (user.getEmailAddr().equals("")) {
return null;
}
InternetAddress email_addr = new InternetAddress(user.getEmailAddr());
EndUserBaseMail mail;
if (user.getLanguage() == null) {
mail = new EndUserBaseMail(Locale.getDefault(), "adduserftpserver", email_addr);
} else {
mail = new EndUserBaseMail(Lang.getLocale(user.getLanguage()), "adduserftpserver", email_addr);
}
HashMap<String, Object> mail_vars = new HashMap<String, Object>();
mail_vars.put("login", ftp_user.getName());
mail_vars.put("password", clear_password);
if (Configuration.global.isElementExists("ftpserveradmin_hostsbydomain")) {
String domain = ftp_user.getDomain();
if (domain.equals("")) {
domain = "default";
}
if (Configuration.global.isElementKeyExists("ftpserveradmin_hostsbydomain", domain)) {
if (Configuration.isElementKeyExists(Configuration.global.getElement("ftpserveradmin_hostsbydomain"), domain, "host")) {
String host = (String) Configuration.getRawValue(Configuration.global.getElement("ftpserveradmin_hostsbydomain"), domain, "host");
mail_vars.put("host", host);
mail_vars.put("uri", "ftp://" + ftp_user.getName() + ":" + clear_password + "@" + host + "/");
}
}
}
if (mail_vars.containsKey("host") == false) {
mail_vars.put("host", "(no set in configuration for this domain)");
}
if (mail_vars.containsKey("uri") == false) {
mail_vars.put("uri", "(no set in configuration for this domain)");
}
mail.send(mail_vars);
return null;
}