7234

NHibernate Validation Localization with S#arp Architecture

I'm trying to localize error messages from NHibernate.Validator. From what I have read, the messages should automaticaly be localized if I set the CurrentCulture/CurrentUICultule ; wich I tried without success. I'm using S#arp Architecture with the default configuration. As I said, the only thnig I changed is the CurrentCulture/CurrentUICultule.

Do I have to create a custom message interpolator for nhibernate validator?

Answer1:

I have posted in my blog about creating a Custom Interpolator that overrides the default messages if they exist in your resources. It allows you to override the default messages and add new messages for your validators. Check it out: NHibernate Validator Custom Messages

Answer2:

Changing the culture for was not a good idea, since all my website is in spanish, so the path that I took was to create a SpanishMessageInterpolator and then set it up in my nhv.config like:

<property name="message_interpolator_class">NHibernateValidator.SpanishMessageInterpolator, Assembly</property>

And finally I did modify my global.asax.cs file to include the nhv.config file on NHibernate initialization, like:

NHibernateSession.Init( webSessionStorage, new string[] { Server.MapPath("~/bin/Assembly.dll") }, new AutoPersistenceModelGenerator().Generate(), Server.MapPath("~/NHibernate.config"), Server.MapPath("~/nhv.config"));

Recommend

  • How to produce X values of a stretched graph?
  • scalafx.animation.Timeline not working as expected
  • NHibernate - Could not execute query - Input string was not in a correct format
  • how to git push with maven
  • How do I get NHibernate to save an entity if I assign it an ID, but generate one otherwise?
  • Generate a business key
  • Spring bean validation messages resolution
  • Translate animation to correct position in Android
  • Doctrine2 inverse persistance not working in nested forms
  • Emacs lua-mode issue: (void-function interactively-called-p)
  • back button function for phonegap windows phone 7
  • Create function that can pass a parameter without making a new component
  • jquery validation - waiting for remote check to complete
  • uml Composition relationships to RDF and OWL
  • Why cepheus don't send int without quotes to orion?
  • Loading .coffee files via a view in Rails
  • Eloquent update method change created_at timestamp
  • custom UITableViewCell with image for highlighting
  • How do I access an unhandled exception in an MVC Error view?
  • Retrieve list of sent friend requests from friend_request FQL table
  • Google Custom Search with transparent background
  • C++ Partial template specialization - design simplification
  • ImageMagick, replace semi-transparent white with opaque white
  • NHibernate Validation Localization with S#arp Architecture
  • Spring Data JPA custom method causing PropertyReferenceException
  • How can I send an e-mail from a vbs script
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Accessing IRQ description array within a module and displaying action names
  • Bug in WPF DataGrid
  • Excel - Autoshape get it's name from cell (value)
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Redux, normalised entities and lodash merge
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • Getting Messege Twice Using IMvxMessenger
  • JaxB to read class hierarchy
  • How to get NHibernate ISession to cache entity not retrieved by primary key