当前位置: 首页>>代码示例>>Java>>正文


Java Lang类代码示例

本文整理汇总了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;
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:EmailComposerImpl.java

示例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);
}
 
开发者ID:CSCfi,项目名称:exam,代码行数:17,代码来源:EmailComposerImpl.java

示例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);
}
 
开发者ID:Vadus,项目名称:songs_play,代码行数:22,代码来源:MyUsernamePasswordAuthProvider.java

示例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);
}
 
开发者ID:Vadus,项目名称:songs_play,代码行数:21,代码来源:MyUsernamePasswordAuthProvider.java

示例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);
}
 
开发者ID:Vadus,项目名称:songs_play,代码行数:21,代码来源:MyUsernamePasswordAuthProvider.java

示例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));
        }
    });
}
 
开发者ID:vangav,项目名称:vos_backend,代码行数:20,代码来源:SimpleTest.java

示例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;
}
 
开发者ID:btnguyen2k,项目名称:queue-server,代码行数:35,代码来源:BaseController.java

示例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;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:21,代码来源:CalendarBinder.java

示例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;
}
 
开发者ID:eBay,项目名称:restcommander,代码行数:23,代码来源:AnnotationHelper.java

示例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);
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:22,代码来源:GSNUsernamePasswordAuthProvider.java

示例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);
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:21,代码来源:GSNUsernamePasswordAuthProvider.java

示例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);
}
 
开发者ID:LSIR,项目名称:gsn,代码行数:21,代码来源:GSNUsernamePasswordAuthProvider.java

示例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();
}
 
开发者ID:stefanil,项目名称:play2-prototypen,代码行数:19,代码来源:ActionTest.java

示例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);
}
 
开发者ID:stefanil,项目名称:play2-prototypen,代码行数:22,代码来源:MyUsernamePasswordAuthProvider.java

示例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);
}
 
开发者ID:stefanil,项目名称:play2-prototypen,代码行数:21,代码来源:MyUsernamePasswordAuthProvider.java


注:本文中的play.i18n.Lang类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。