congrats Icon
New! Announcing our next generation AI code completions
Read here
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

    • Start an intent from android
    • getApplicationContext (Context)
    • addToBackStack (FragmentTransaction)
    • setContentView (Activity)
    • FileNotFoundException (java.io)
      Thrown when a file specified by a program cannot be found.
    • SocketException (java.net)
      This SocketException may be thrown during socket creation or setting options, and is the superclass
    • ByteBuffer (java.nio)
      A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
    • TimeUnit (java.util.concurrent)
      A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
    • Collectors (java.util.stream)
    • LogFactory (org.apache.commons.logging)
      Factory for creating Log instances, with discovery and configuration features similar to that employ
    • Sublime Text for Python
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

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