web/play-java-forms/src/main/java/play/data/Form.java
private static <T> T withRequestLocale(Lang lang, Supplier<T> code) {
    try {
      LocaleContextHolder.setLocale(lang != null ? lang.toLocale() : null);
    } catch (Exception e) {
      // Just continue (Maybe there is no context or some internal error in LocaleContextHolder).
      // System default locale will be used.
    }
    try {
      return code.get();
    } finally {
      LocaleContextHolder.resetLocaleContext(); // Clean up ThreadLocal
    }
  }
private static <T> T withRequestLocale(Lang lang, Supplier<T> code) {
    try {
      LocaleContextHolder.setLocale(lang != null ? lang.toLocale() : null);
    } catch (Exception e) {
      // Just continue (Maybe there is no context or some internal error in LocaleContextHolder).
      // System default locale will be used.
    }
    try {
      return code.get();
    } finally {
      LocaleContextHolder.resetLocaleContext(); // Clean up ThreadLocal
    }
  }
private static < T > T withRequestLocale ( Lang lang , Supplier < T > code ) { try { LocaleContextHolder . setLocale ( lang != null ? lang . toLocale ( ) : null ) ; } catch ( Exception e ) { // Just continue (Maybe there is no context or some internal error in LocaleContextHolder). // System default locale will be used. } try { return code . get ( ) ; } finally { LocaleContextHolder . resetLocaleContext ( ) ; // Clean up ThreadLocal } }
Sets the locale of the current request (if there is one) into Spring's LocaleContextHolder.

@param <T> the return type.
@param code The code to execute while the locale is set
@return the result of the code block
Sets the locale of the current request ( if there is one ) into Spring s LocaleContextHolder .