title: Validation messages from custom model validation attributes are locked to first loaded language
body: <p>I am working on a multi lingual website using Umbraco 7.2.4 (.NET MVC 4.5). I have pages for each language nested under home nodes with their own culture:</p>
  
  <ul>
  <li>Home (language selection)
  
  <ul>
  <li>nl-BE
  
  <ul>
  <li>some page</li>
  <li>some other page</li>
  <li>my form page</li>
  </ul></li>
  <li>fr-BE
  
  <ul>
  <li>some page</li>
  <li>some other page</li>
  <li>my form page</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <p>The form model is decorated with validation attributes that I needed to translate for each language.  I found a Github project, <a href="https://github.com/warrenbuckley/Umbraco-Validation-Attributes" rel="nofollow">Umbraco Validation Attributes</a> that extends decoration attributes to retrieve validation messages from Umbraco dictionary items. It works fine for page content but not validation messages.</p>
  
  <h3>The issue</h3>
  
  <ul>
  <li>land on nl-BE/form
  
  <ul>
  <li>field labels are shown in dutch (nl-BE)</li>
  </ul></li>
  <li>submit invalid form
  
  <ul>
  <li>validation messages are shown in dutch (nl-BE culture)</li>
  </ul></li>
  <li>browse to fr-BE/form
  
  <ul>
  <li>field labels are shown in french (fr-BE)</li>
  </ul></li>
  <li>submit invalid form
  
  <ul>
  <li>Expected behavior is: validation messages are shown in french (fr-BE culture)</li>
  <li>Actual behavior is: messages are still shown in dutch (data-val-required attribute is in dutch in the source of the page)</li>
  </ul></li>
  </ul>
  
  <h2>Investigation to date</h2>
  
  <p>This is not a browser cache issue, it is reproducible across separate browsers, even separate computers: whoever is generating the form for the first time will lock the validation message culture. The only way to change the language of the validation messages is to recycle the Application Pool.</p>
  
  <p>I doubt that the Umbraco Validation helper class is the issue here but I'm out of ideas, so any insight is appreciated.</p>
  
  <h2>Source code</h2>
  
  <p>Model</p>
  
  <pre><code>public class MyFormViewModel : RenderModel
  {
      public class PersonalDetails
      {
          [UmbracoDisplayName("FORMS_FIRST_NAME")]
          [UmbracoRequired("FORMS_FIELD_REQUIRED_ERROR")]
          public String FirstName { get; set; }
      }
  }
  </code></pre>
  
  <p>View</p>
  
  <pre><code>@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
  var model = new MyFormViewModel();
  using (Html.BeginUmbracoForm&lt;MyFormController&gt;("SubmitMyForm", null, new {id = "my-form"}))
  { 
              &lt;h3&gt;@LanguageHelper.GetDictionaryItem("FORMS_HEADER_PERSONAL_DETAILS")&lt;/h3&gt;
          &lt;div class="field-wrapper"&gt;
              @Html.LabelFor(m =&gt; model.PersonalDetails.FirstName)
              &lt;div class="input-wrapper"&gt;
                  @Html.TextBoxFor(m =&gt; model.PersonalDetails.FirstName)
                  @Html.ValidationMessageFor(m =&gt; model.PersonalDetails.FirstName)
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>note: I have used the native MVC Html.BeginForm method as well, same results.</p>
  
  <p>Controller</p>
  
  <pre><code>public ActionResult SubmitFranchiseApplication(FranchiseFormViewModel viewModel)
      {
          if (!ModelState.IsValid)
          {
              TempData["Message"] = LanguageHelper.GetDictionaryItem("FORMS_VALIDATION_FAILED_MESSAGE");
              foreach (ModelState modelState in ViewData.ModelState.Values)
              {
                  foreach (ModelError error in modelState.Errors)
                  {
                      TempData["Message"] += "&lt;br/&gt;" + error.ErrorMessage;
                  }
              }
  
              return RedirectToCurrentUmbracoPage();
          }
      }
  </code></pre>
  
  <p>LanguageHelper</p>
  
  <pre><code>public class LanguageHelper
  {
      public static string CurrentCulture
      {
          get
          {
              return UmbracoContext.Current.PublishedContentRequest.Culture.ToString();
              // I also tried using the thread culture
              return System.Threading.Thread.CurrentThread.CurrentCulture.ToString(); 
          }
      }
      public static string GetDictionaryItem(string key)
      {
          var value = library.GetDictionaryItem(key);
          return string.IsNullOrEmpty(value) ? key : value;
      }
  }
  </code></pre>