title: Form errors i18n Play framework
body: <p>I'm using the form helper and a custom form template to render my forms in the Play framework like this:</p>
  
  <pre><code>@(lang: Lang)(myForm: Form[MyModel])
  
  @import play.i18n._
  @import helper._
  
  @implicitField = @{ FieldConstructor(formTemplate.f) }
  
  @form ( action = routes.Application.index() ){
      @inputText(
          field = myForm("username"),
          '_label -&gt; Messages.get(lang, "username")
      )
  }
  </code></pre>
  
  <p>When the template is called with different values for <code>lang</code>, the label is displayed in the respective language. </p>
  
  <p>However, when the form is submitted, <strong>error messages are always displayed in the main language</strong>. (i.e. for <code>Required</code> fields it's always <code>This field is required.</code>)</p>
  
  <p>As <a href="https://stackoverflow.com/a/11265036/538047">the answer</a> to <a href="https://stackoverflow.com/q/11263712/538047" title="Overriding default i18n messages for play 2.0">this post</a> mentioned, I changed the default error messages like so in my language files (currently only 2):</p>
  
  <p><strong>messages.en</strong>:</p>
  
  <pre><code>username=Username
  error.required=This field is required
  </code></pre>
  
  <p><strong>messages.nl</strong>:</p>
  
  <pre><code>username=Gebruikersnaam
  error.required=Dit veld is verplicht
  </code></pre>
  
  <p>How can I make sure the errors are printed in the correct language?</p>
  
  <p>I've already tried doing the following in my custom template, but without success:</p>
  
  <pre><code>@(elements: helper.FieldElements)
  
  &lt;!-- snipped some HTML code --&gt;
  &lt;span class="help"&gt;
      @(elements.infos(elements.args.get('_lang) match { 
          case Some(language) =&gt; language.asInstanceOf[play.api.i18n.Lang] 
          case None =&gt; new Lang("en","uk")
      }).mkString(", "))
  &lt;/span&gt;             
  </code></pre>
  
  <p>And by adding <code>'_lang -&gt; lang</code> to my <code>@inputText</code> call.</p>
  
  <p>I'm used to programming in Java and have only done some Scala in the Play templates. I'm using Play 2.0.4.</p>