Note that there are some explanatory texts on larger screens.

plurals
  1. POnhibernate validator (1.3.1) localizing error messages
    primarykey
    data
    text
    <p>I created an unit test case for displaying error messages in a different language than English but it doesn't seem to work and I don't know what I am missing.</p> <p>Here are the details:</p> <p>I am using attributes.</p> <p>app.config (I excluded the nhibernate cfg):</p> <pre><code>&lt;configSections&gt; &lt;section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/&gt; &lt;section name="nhv-configuration" type="NHibernate.Validator.Cfg.ConfigurationSectionHandler, NHibernate.Validator" /&gt; &lt;/configSections&gt; &lt;nhv-configuration xmlns="urn:nhv-configuration-1.0"&gt; &lt;property name='apply_to_ddl'&gt;false&lt;/property&gt; &lt;property name='autoregister_listeners'&gt;true&lt;/property&gt; &lt;property name='default_validator_mode'&gt;OverrideExternalWithAttribute&lt;/property&gt; &lt;/nhv-configuration&gt; </code></pre> <p>Initialization of the validator:</p> <pre><code>private void InitializeValidator() { var provider = new NHibernateSharedEngineProvider(); provider.GetEngine().Configure(); NHibernate.Validator.Cfg.Environment.SharedEngineProvider = provider; } </code></pre> <p>The test function (EntityDescription is my entity class and the Repository follows the sharp architecture design with Repository classes):</p> <pre><code>[Test] public void TestNhValidationSp() { CultureInfo ci = CultureInfo.GetCultureInfo("fr"); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; TestNhValidation(); } private void TestNhValidation() { IEntityDescriptionRepository repository = GetObject&lt;IEntityDescriptionRepository&gt;(); ISession session = NHibernateSession.Current; EntityDescription entityDescription= (from kpad in session.Query&lt;EntityDescription&gt;() select kpad).FirstOrDefault(); entityDescription.Title = "012345678901234567890123456789012345678901234567890123456789"; try { repository.SaveOrUpdateWithTransaction(entityDescription); Assert.IsTrue(false); } catch (Exception ex) { Console.WriteLine(ex.Message); Assert.IsTrue(ex is InvalidStateException); InvalidStateException isex = (InvalidStateException) ex; foreach (InvalidValue invalidValue in isex.GetInvalidValues()) { Console.WriteLine("PropertyName={0} Message={1}", invalidValue.PropertyName, invalidValue.Message); } } } </code></pre> <p>Setting entityDescription.Title = "012345678901234567890123456789012345678901234567890123456789";</p> <p>will trigger a validation error because the title can have up to 50 chars.</p> <p>The problem is that the message always comes in English. Any thoughts?</p> <p>One thing I want to add is that my test project has a dependency on the SharpArchitecture project (1.9.5). I wonder if somehow this screws up my nhibernate validator cnfiguration.</p> <p>Found this message: <a href="https://stackoverflow.com/questions/1191309/nhibernate-validation-localization-with-sarp-architecture">NHibernate Validation Localization with S#arp Architecture</a> that reports a similar problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload