Localization support

Topics: Validation Application Block
Jan 24, 2007 at 2:27 AM
I attended David Hayden's presentation to the SarasotaDev.net about the VAB.

How does the VAB support localization for config and attribute driven validation. In particular, I am concerned about the validation messages, string and numeric comparisons (could be english units versus metric). Does VAB support CultureInfos or some other localization mechanism.

Thanks,

Dale
Jan 24, 2007 at 6:47 PM
Hi Dale -

The VAB lets you specify the message template to use through both configuration and attributes. This can be a literal string, or a reference to a resource (type + name). The resource gets loaded using the thread's CurrentUICulture. If you want to have different messages displayed for different users, you can the CurrentUICulture to a different culture and it should result the message being loaded from the appropriate resource file.

I'm not sure I understand the scenarios where the culture would implement the logic of the validation itself. If any validators rely on Thread.CurrentCulture, you could of course reset this in the same way as described above. We don't have an overload to Validate where you can explictly pass in a culture that should be used instead of the current culture. Can you think of any scenarios where this would be important?

thanks
Tom
Jan 26, 2007 at 1:37 PM
Sorry for the confusion Tom, I was basically just asking if and how multiple cultures are supported. We sometimes switch cultures "on the fly" (many of our applications allow a single user to edit in multiple languages, for instance) and we should be able to work with the CurrentUICulture to achieve what we need.

Thanks.