Validation Application Block is multilingual?

Topics: Validation Application Block
Apr 20, 2007 at 2:15 PM
You do not specify if the Validation Application Block is multilingual. This is me who hasn’t found this information or it’s not implemented yet?
The message of all validators must be in English and in French. Do you expect to implement this soon?
Apr 20, 2007 at 5:20 PM
This is already supported. For each validator you can specify a MessageTemplateResourceName and MessageTemplateResourceTypeName. The message template will be retreived from resources at runtime using the CurrentUICulture.

Tom
Apr 27, 2007 at 4:51 PM
I'm investigating something similar as well. I want to pass the validation results along with some kind of functional FaultException. But I want to include the validation messages in multiple languages so that the WCF client can determine the most appropriate message to display to its end-users.
May 15, 2007 at 5:45 PM
Tom,

I was wondering how this would work in an ASP.NET server environment where you have a server which is always running on the same culture regardless of the type of client (say, smart client) connected. Is there any way to explicitly tell the VAB to use a specific culture when retrieving resources? In my project we dont rely on CurrentUICulture on the server for localization purposes..instead we register each users preferred culture in our database which is then used for localization purposes. Instead of the built in resx resource class generator that ships with .NET, we use a custom tool that can generate resource classes that will take a culture as input.

Thank you.
Allan Rasmussen
May 16, 2007 at 8:07 AM
Allen,

VAB will use the thread's CurrentUICulture automatically. So, what you can do, is force the thread's culture prior to calling the VAB's validation facade. The only thing you can't easily change is the resource managemenet classes. VAB will use the default ResourceManager to resolve any resources. Forcing the current culture can be done using:

using System.Threading;
Thread.CurrentCulture = new CultureInfo("en-EN");

Regards,
Dennis Doomen
Aviva Solutions
May 22, 2007 at 3:44 PM
Allan,

The CurrentUICulture setting that Tom is referring to is per thread and not per server or OS setting. You can very easily set the CurrentCulture and CurrentUICulture from the client based on the web browser's preferred language settings, the user's specific choice or whatever source you want to use to determine the language to present to the user.

Morten
May 22, 2007 at 11:55 PM
Hi Morten,

Yes, I realize this, but we dont want to set the current UI culture at will on the server. Preferably, we want it to stay in english because it influences other stuff like in what languages are exceptions thrown on the server. Imagine having to go through bulgarien WCF exception messages in your event viewer, because you accidentally mess around with the UI culture.
May 23, 2007 at 6:07 AM
Allan,

You don't have to set it at will. Simply set it prior to your call to Validation.Validate() and then reset it back to its original value. That should do it for you.

Regards,

Dennis