本文整理汇总了Java中play.i18n.Lang类的典型用法代码示例。如果您正苦于以下问题:Java Lang类的具体用法?Java Lang怎么用?Java Lang使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Lang类属于play.i18n包,在下文中一共展示了Lang类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createReservationEvent
import play.i18n.Lang; //导入依赖的package包/类
private ICalendar createReservationEvent(Lang lang, DateTime start, DateTime end, String address, String... placeInfo) {
List<String> info = Stream.of(placeInfo)
.filter(s -> s != null && !s.isEmpty())
.collect(Collectors.toList());
ICalendar iCal = new ICalendar();
iCal.setVersion(ICalVersion.V2_0);
VEvent event = new VEvent();
Summary summary = event.setSummary(messaging.get(lang, "ical.reservation.summary"));
summary.setLanguage(lang.code());
event.setDateStart(start.toDate());
event.setDateEnd(end.toDate());
event.setLocation(address);
event.setDescription(messaging.get(lang, "ical.reservation.room.info", String.join(", ", info)));
iCal.addEvent(event);
return iCal;
}
示例2: composeNoShowMessage
import play.i18n.Lang; //导入依赖的package包/类
@Override
public void composeNoShowMessage(User toUser, User student, Exam exam) {
String templatePath = getTemplatesRoot() + "noShow.html";
String template = readFile(templatePath, ENCODING);
Lang lang = getLang(toUser);
boolean isMaturity = exam.getExecutionType().getType().equals(ExamExecutionType.Type.MATURITY.toString());
String templatePrefix = String.format("email.template%s.", isMaturity ? ".maturity" : "");
String subject = messaging.get(lang, templatePrefix + "noshow.subject");
String message = messaging.get(lang, "email.template.noshow.message", String.format("%s %s <%s>",
student.getFirstName(), student.getLastName(), student.getEmail()),
String.format("%s (%s)", exam.getName(), exam.getCourse().getCode()));
Map<String, String> stringValues = new HashMap<>();
stringValues.put("message", message);
String content = replaceAll(template, stringValues);
emailSender.send(toUser.getEmail(), SYSTEM_ACCOUNT, subject, content);
}
示例3: getVerifyEmailMailingBody
import play.i18n.Lang; //导入依赖的package包/类
@Override
protected Body getVerifyEmailMailingBody(final String token,
final MyUsernamePasswordAuthUser user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_VERIFICATION_LINK_SECURE);
final String url = routes.Signup.verify(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
final String text = getEmailTemplate(
"views.txt.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
return new Body(text, html);
}
示例4: getPasswordResetMailingBody
import play.i18n.Lang; //导入依赖的package包/类
protected Body getPasswordResetMailingBody(final String token,
final User user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_PASSWORD_RESET_LINK_SECURE);
final String url = routes.Signup.resetPassword(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.email.password_reset", langCode, url,
token, user.name, user.email);
final String text = getEmailTemplate(
"views.txt.account.email.password_reset", langCode, url, token,
user.name, user.email);
return new Body(text, html);
}
示例5: getVerifyEmailMailingBodyAfterSignup
import play.i18n.Lang; //导入依赖的package包/类
protected Body getVerifyEmailMailingBodyAfterSignup(final String token,
final User user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_VERIFICATION_LINK_SECURE);
final String url = routes.Signup.verify(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.email.verify_email", langCode, url, token,
user.name, user.email);
final String text = getEmailTemplate(
"views.txt.account.email.verify_email", langCode, url, token,
user.name, user.email);
return new Body(text, html);
}
示例6: errorsAsJson
import play.i18n.Lang; //导入依赖的package包/类
@Test
public void errorsAsJson() {
running(fakeApplication(), new Runnable() {
@Override
public void run() {
Lang lang = new Lang(new play.api.i18n.Lang("en", ""));
Map<String, List<ValidationError>> errors = new HashMap<String, List<ValidationError>>();
List<ValidationError> error = new ArrayList<ValidationError>();
error.add(new ValidationError("foo", RequiredValidator.message, new ArrayList<Object>()));
errors.put("foo", error);
DynamicForm form = new DynamicForm(new HashMap<String, String>(), errors, F.None());
JsonNode jsonErrors = form.errorsAsJson(lang);
assertThat(jsonErrors.findPath("foo").iterator().next().asText()).isEqualTo(play.i18n.Messages.get(lang, RequiredValidator.message));
}
});
}
示例7: render
import play.i18n.Lang; //导入依赖的package包/类
/**
* Utility method to render a HTML page.
*
* @param view
* @param params
* @return
* @throws InstantiationException
* @throws IllegalAccessException
* @throws ClassNotFoundException
* @throws SecurityException
* @throws NoSuchMethodException
* @throws IllegalArgumentException
* @throws InvocationTargetException
*/
protected static Html render(String view, Object... params) throws InstantiationException,
IllegalAccessException, ClassNotFoundException, SecurityException,
NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
String clazzName = "views.html." + view;
Class<?> clazz = Class.forName(clazzName);
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals("render")) {
Lang lang = lang();
Object[] combinedParams = new Object[params.length + 1];
combinedParams[params.length] = lang;
for (int i = 0; i < params.length; i++) {
combinedParams[i] = params[i];
}
return (Html) method.invoke(null, combinedParams);
}
}
return null;
}
示例8: bind
import play.i18n.Lang; //导入依赖的package包/类
public Calendar bind(String name, Annotation[] annotations, String value, Class actualClass, Type genericType) throws Exception {
if (value == null || value.trim().length() == 0) {
return null;
}
Calendar cal = Calendar.getInstance(Lang.getLocale());
try {
Date date = AnnotationHelper.getDateAs(annotations, value);
if (date != null) {
cal.setTime(date);
} else {
SimpleDateFormat sdf = new SimpleDateFormat(I18N.getDateFormat());
sdf.setLenient(false);
cal.setTime(sdf.parse(value));
}
} catch (ParseException e) {
throw new IllegalArgumentException("Cannot convert [" + value + "] to a Calendar: " + e.toString());
}
return cal;
}
示例9: 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;
}
示例10: getVerifyEmailMailingBody
import play.i18n.Lang; //导入依赖的package包/类
@Override
protected Body getVerifyEmailMailingBody(final String token,
final GSNUsernamePasswordAuthUser user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_VERIFICATION_LINK_SECURE);
final String url = controllers.gsn.auth.routes.Signup.verify(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
final String text = getEmailTemplate(
"views.txt.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
return new Body(text, html);
}
示例11: getPasswordResetMailingBody
import play.i18n.Lang; //导入依赖的package包/类
protected Body getPasswordResetMailingBody(final String token,
final User user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_PASSWORD_RESET_LINK_SECURE);
final String url = controllers.gsn.auth.routes.Signup.resetPassword(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.email.password_reset", langCode, url,
token, user.name, user.email);
final String text = getEmailTemplate(
"views.txt.account.email.password_reset", langCode, url, token,
user.name, user.email);
return new Body(text, html);
}
示例12: getVerifyEmailMailingBodyAfterSignup
import play.i18n.Lang; //导入依赖的package包/类
protected Body getVerifyEmailMailingBodyAfterSignup(final String token,
final User user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_VERIFICATION_LINK_SECURE);
final String url = controllers.gsn.auth.routes.Signup.verify(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.account.email.verify_email", langCode, url, token,
user.name, user.email);
final String text = getEmailTemplate(
"views.txt.account.email.verify_email", langCode, url, token,
user.name, user.email);
return new Body(text, html);
}
示例13: testCreate
import play.i18n.Lang; //导入依赖的package包/类
/**
* Tests individual creation without associating with a specific point.
*/
@Test
public void testCreate() {
Action startGame = new Action();
startGame.heading = Messages.get(Lang.forCode("en"),
"common.actions.StartGame.heading");
startGame.info = Messages.get(Lang.forCode("en"),
"common.actions.StartGame.info");
startGame.button = Messages.get(Lang.forCode("en"),
"common.actions.StartGame.button");
startGame.save();
assertThat(startGame.id).isNotNull();
// delete specific action from all points
deleteManyToMany(startGame);
startGame.delete();
}
示例14: getVerifyEmailMailingBody
import play.i18n.Lang; //导入依赖的package包/类
@Override
protected Body getVerifyEmailMailingBody(final String token,
final MyUsernamePasswordAuthUser user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_VERIFICATION_LINK_SECURE);
final String url = routes.Signup.verify(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.common.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
final String text = getEmailTemplate(
"views.txt.common.account.signup.email.verify_email", langCode, url,
token, user.getName(), user.getEmail());
return new Body(text, html);
}
示例15: getPasswordResetMailingBody
import play.i18n.Lang; //导入依赖的package包/类
protected Body getPasswordResetMailingBody(final String token,
final User user, final Context ctx) {
final boolean isSecure = getConfiguration().getBoolean(
SETTING_KEY_PASSWORD_RESET_LINK_SECURE);
final String url = routes.Signup.resetPassword(token).absoluteURL(
ctx.request(), isSecure);
final Lang lang = Lang.preferred(ctx.request().acceptLanguages());
final String langCode = lang.code();
final String html = getEmailTemplate(
"views.html.common.account.email.password_reset", langCode, url,
token, user.name, user.email);
final String text = getEmailTemplate(
"views.txt.common.account.email.password_reset", langCode, url, token,
user.name, user.email);
return new Body(text, html);
}