/** * Translates a message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param lang the message lang * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String get(play.api.i18n.Lang lang, String key, Object... args) { Buffer<Object> scalaArgs = convertArgsToScalaBuffer(args); return messages.apply(key, scalaArgs, lang); }
/** * Check if a message key is defined. * * @param lang the message lang * @param key the message key * @return a Boolean */ public Boolean isDefinedAt(play.api.i18n.Lang lang, String key) { return messages.isDefinedAt(key, lang); }
public boolean langCookieHttpOnly() { return messages.langCookieHttpOnly(); }
/** * 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. */ public Messages preferred(Http.RequestHeader request) { play.api.i18n.Messages msgs = messages.preferred(request); return new Messages(new Lang(msgs.lang()), this); }
public String langCookieName() { return messages.langCookieName(); }
public boolean langCookieSecure() { return messages.langCookieSecure(); }
/** * Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang. * * @param result the result where the lang will be set. * @param lang the lang to set on the result * @return a new result with the lang. */ public Result setLang(Result result, Lang lang) { return messages.setLang(result.asScala(), lang).asJava(); }
/** * Given a Result, return a new Result with the lang cookie discarded. * * @param result the result to clear the lang. * @return a new result with a cleared lang. */ public Result clearLang(Result result) { return messages.clearLang(result.asScala()).asJava(); }
@Override default MessagesApi messagesApi() { return new DefaultMessagesApiProvider( environment().asScala(), configuration(), langs().asScala(), httpConfiguration() ).get().asJava(); }
public Optional<Http.Cookie.SameSite> langCookieSameSite() { return OptionConverters.toJava(messages.langCookieSameSite()).map(sameSite -> sameSite.asJava()); }
/** * 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); }
public String langCookieName() { return messages.langCookieName(); }
public boolean langCookieSecure() { return messages.langCookieSecure(); }
/** * Given a Result and a Lang, return a new Result with the lang cookie set to the given Lang. * * @param result the result where the lang will be set. * @param lang the lang to set on the result * @return a new result with the lang. */ public Result setLang(Result result, Lang lang) { return messages.setLang(result.asScala(), lang).asJava(); }
/** * Given a Result, return a new Result with the lang cookie discarded. * * @param result the result to clear the lang. * @return a new result with a cleared lang. */ public Result clearLang(Result result) { return messages.clearLang(result.asScala()).asJava(); }
@Override default MessagesApi messagesApi() { return new DefaultMessagesApiProvider( environment().asScala(), configuration(), langs().asScala(), httpConfiguration() ).get().asJava(); }
public Optional<Http.Cookie.SameSite> langCookieSameSite() { return OptionConverters.toJava(messages.langCookieSameSite()).map(sameSite -> sameSite.asJava()); }
/** * 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); }
/** * Translates a message. * * Uses `java.text.MessageFormat` internally to format the message. * * @param lang the message lang * @param key the message key * @param args the message arguments * @return the formatted message or a default rendering if the key wasn't defined */ public String get(play.api.i18n.Lang lang, String key, Object... args) { Seq<Object> scalaArgs = convertArgsToScalaBuffer(args); return messages.apply(key, scalaArgs, lang); }
/** * Check if a message key is defined. * * @param lang the message lang * @param key the message key * @return a Boolean */ public Boolean isDefinedAt(play.api.i18n.Lang lang, String key) { return messages.isDefinedAt(key, lang); }