Tabnine Logo
MessagesImpl.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
play.i18n.MessagesImpl
constructor

Best Java code snippets using play.i18n.MessagesImpl.<init> (Showing top 12 results out of 315)

origin: com.typesafe.play/play_2.12

/**
 * Get a messages context appropriate for the given request.
 *
 * Will select a language from the request, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param request the incoming request
 * @return the preferred messages context for the request
 */
public Messages preferred(Http.RequestHeader request) {
  play.api.i18n.Messages msgs = messages.preferred(request);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play

/**
 * Get a messages context appropriate for the given request.
 *
 * Will select a language from the request, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param request the incoming request
 * @return the preferred messages context for the request
 */
public Messages preferred(Http.RequestHeader request) {
  play.api.i18n.Messages msgs = messages.preferred(request);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play_2.11

/**
 * Get a messages context appropriate for the given request.
 *
 * Will select a language from the request, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param request the incoming request
 * @return the preferred messages context for the request
 */
public Messages preferred(Http.RequestHeader request) {
  play.api.i18n.Messages msgs = messages.preferred(request);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play_2.12

/**
 * Get a messages context appropriate for the given candidates.
 *
 * Will select a language from the candidates, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param candidates the candidate languages
 * @return the most appropriate Messages instance given the candidate languages
 */
public Messages preferred(Collection<Lang> candidates) {
  Seq<Lang> cs = Scala.asScala(candidates);
  play.api.i18n.Messages msgs = messages.preferred((Seq)cs);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play_2.11

/**
 * Get a messages context appropriate for the given candidates.
 *
 * Will select a language from the candidates, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param candidates the candidate languages
 * @return the most appropriate Messages instance given the candidate languages
 */
public Messages preferred(Collection<Lang> candidates) {
  Seq<Lang> cs = Scala.asScala(candidates);
  play.api.i18n.Messages msgs = messages.preferred((Seq)cs);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play

/**
 * Get a messages context appropriate for the given candidates.
 *
 * Will select a language from the candidates, based on the languages available, and fallback to the default language
 * if none of the candidates are available.
 *
 * @param candidates the candidate languages
 * @return the most appropriate Messages instance given the candidate languages
 */
public Messages preferred(Collection<Lang> candidates) {
  Seq<Lang> cs = Scala.asScala(candidates);
  play.api.i18n.Messages msgs = messages.preferred((Seq)cs);
  return new MessagesImpl(new Lang(msgs.lang()), this);
}
origin: com.typesafe.play/play-java-forms_2.12

private Set<ConstraintViolation<Object>> runValidation(Lang lang, TypedMap attrs, DataBinder dataBinder, Map<String, Object> objectData) {
  return withRequestLocale(lang, () -> {
    dataBinder.bind(new MutablePropertyValues(objectData));
    final ValidationPayload payload = new ValidationPayload(lang, lang != null ? new MessagesImpl(lang, this.messagesApi) : null, Http.Context.safeCurrent().map(ctx -> ctx.args).orElse(null), attrs, this.config);
    final Validator validator = validatorFactory.unwrap(HibernateValidatorFactory.class).usingContext().constraintValidatorPayload(payload).getValidator();
    if (groups != null) {
      return validator.validate(dataBinder.getTarget(), groups);
    } else {
      return validator.validate(dataBinder.getTarget());
    }
  });
}
origin: com.typesafe.play/play-java-forms

private Set<ConstraintViolation<Object>> runValidation(Lang lang, TypedMap attrs, DataBinder dataBinder, Map<String, Object> objectData) {
  return withRequestLocale(lang, () -> {
    dataBinder.bind(new MutablePropertyValues(objectData));
    final ValidationPayload payload = new ValidationPayload(lang, lang != null ? new MessagesImpl(lang, this.messagesApi) : null, Http.Context.safeCurrent().map(ctx -> ctx.args).orElse(null), attrs, this.config);
    final Validator validator = validatorFactory.unwrap(HibernateValidatorFactory.class).usingContext().constraintValidatorPayload(payload).getValidator();
    if (groups != null) {
      return validator.validate(dataBinder.getTarget(), groups);
    } else {
      return validator.validate(dataBinder.getTarget());
    }
  });
}
origin: com.typesafe.play/play-java-forms_2.11

private Set<ConstraintViolation<Object>> runValidation(Lang lang, TypedMap attrs, DataBinder dataBinder, Map<String, Object> objectData) {
  return withRequestLocale(lang, () -> {
    dataBinder.bind(new MutablePropertyValues(objectData));
    final ValidationPayload payload = new ValidationPayload(lang, lang != null ? new MessagesImpl(lang, this.messagesApi) : null, Http.Context.safeCurrent().map(ctx -> ctx.args).orElse(null), attrs, this.config);
    final Validator validator = validatorFactory.unwrap(HibernateValidatorFactory.class).usingContext().constraintValidatorPayload(payload).getValidator();
    if (groups != null) {
      return validator.validate(dataBinder.getTarget(), groups);
    } else {
      return validator.validate(dataBinder.getTarget());
    }
  });
}
origin: com.typesafe.play/play-java-forms_2.12

private List<ValidationError> getFieldErrorsAsValidationErrors(Lang lang, BindingResult result) {
  return result.getFieldErrors().stream().map(error -> {
    String key = error.getObjectName() + "." + error.getField();
    if (key.startsWith("target.") && rootName == null) {
      key = key.substring(7);
    }
    if (error.isBindingFailure()) {
      ImmutableList.Builder<String> builder = ImmutableList.builder();
      final Messages msgs = lang != null ? new MessagesImpl(lang, this.messagesApi) : null;
      for (String code: error.getCodes()) {
        code = REPLACE_TYPEMISMATCH.matcher(code).replaceAll(Matcher.quoteReplacement(INVALID_MSG_KEY));
        if (msgs == null || msgs.isDefinedAt(code)) {
          builder.add(code);
        }
      }
      final ImmutableList<String> messages = builder.build();
      return new ValidationError(key, messages.isEmpty() ? Arrays.asList(INVALID_MSG_KEY) : messages.reverse(),
          convertErrorArguments(error.getArguments()));
    } else {
      return new ValidationError(key, error.getDefaultMessage(),
          convertErrorArguments(error.getArguments()));
    }
  }).collect(Collectors.toList());
}
origin: com.typesafe.play/play-java-forms_2.11

private List<ValidationError> getFieldErrorsAsValidationErrors(Lang lang, BindingResult result) {
  return result.getFieldErrors().stream().map(error -> {
    String key = error.getObjectName() + "." + error.getField();
    if (key.startsWith("target.") && rootName == null) {
      key = key.substring(7);
    }
    if (error.isBindingFailure()) {
      ImmutableList.Builder<String> builder = ImmutableList.builder();
      final Messages msgs = lang != null ? new MessagesImpl(lang, this.messagesApi) : null;
      for (String code: error.getCodes()) {
        code = REPLACE_TYPEMISMATCH.matcher(code).replaceAll(Matcher.quoteReplacement(INVALID_MSG_KEY));
        if (msgs == null || msgs.isDefinedAt(code)) {
          builder.add(code);
        }
      }
      final ImmutableList<String> messages = builder.build();
      return new ValidationError(key, messages.isEmpty() ? Arrays.asList(INVALID_MSG_KEY) : messages.reverse(),
          convertErrorArguments(error.getArguments()));
    } else {
      return new ValidationError(key, error.getDefaultMessage(),
          convertErrorArguments(error.getArguments()));
    }
  }).collect(Collectors.toList());
}
origin: com.typesafe.play/play-java-forms

private List<ValidationError> getFieldErrorsAsValidationErrors(Lang lang, BindingResult result) {
  return result.getFieldErrors().stream().map(error -> {
    String key = error.getObjectName() + "." + error.getField();
    if (key.startsWith("target.") && rootName == null) {
      key = key.substring(7);
    }
    if (error.isBindingFailure()) {
      ImmutableList.Builder<String> builder = ImmutableList.builder();
      final Messages msgs = lang != null ? new MessagesImpl(lang, this.messagesApi) : null;
      for (String code: error.getCodes()) {
        code = REPLACE_TYPEMISMATCH.matcher(code).replaceAll(Matcher.quoteReplacement(INVALID_MSG_KEY));
        if (msgs == null || msgs.isDefinedAt(code)) {
          builder.add(code);
        }
      }
      final ImmutableList<String> messages = builder.build();
      return new ValidationError(key, messages.isEmpty() ? Arrays.asList(INVALID_MSG_KEY) : messages.reverse(),
          convertErrorArguments(error.getArguments()));
    } else {
      return new ValidationError(key, error.getDefaultMessage(),
          convertErrorArguments(error.getArguments()));
    }
  }).collect(Collectors.toList());
}
play.i18nMessagesImpl<init>

Popular methods of MessagesImpl

    Popular in Java

    • Running tasks concurrently on multiple threads
    • getOriginalFilename (MultipartFile)
      Return the original filename in the client's filesystem.This may contain path information depending
    • notifyDataSetChanged (ArrayAdapter)
    • getResourceAsStream (ClassLoader)
    • ResultSet (java.sql)
      An interface for an object which represents a database table entry, returned as the result of the qu
    • Locale (java.util)
      Locale represents a language/country/variant combination. Locales are used to alter the presentatio
    • Queue (java.util)
      A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
    • Vector (java.util)
      Vector is an implementation of List, backed by an array and synchronized. All optional operations in
    • HttpServlet (javax.servlet.http)
      Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
    • Logger (org.slf4j)
      The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
    • From CI to AI: The AI layer in your organization
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now