Multilingual Validation Messages.

Topics: Validation Application Block
Apr 22, 2010 at 10:01 PM

I am trying to use the validation error message from resource file and not able to make it work.

I am using only configuration file (Not the attributes) to validate the object. I have resource file created and there is an entry in that. Here is my config for the property to validate.

I am using VAB in WCF service. I am trying to validate the request object in service call and returning the error of validation in the response of the service call.

Now I want to return a error message from service and the message should be in the users language in the parameter.

I am setting culture in the service exposed method using

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

I have my resourec filed named as

Service.PurchaseOrder.Contract.resx

Service.PurchaseOrder.Contract.fr-FR.resx

But the resource string return from the validation result is always english. Whats could be the posssible error? Thanks for your help.

Apr 22, 2010 at 11:38 PM

You should be setting the CurrentUICulture instead of the CurrentCulture.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 26, 2010 at 10:26 PM
Edited Apr 26, 2010 at 10:30 PM

I tried both CurrentCulture and CurrentUICulture.

I have a class that’s in separate assembly and the same assembly contains various resources.

 

 

 

 

 

Apr 27, 2010 at 7:35 AM

Hi,  

Have you already checked your Resource file if its Build Action property is set to "Embedded Resource"?

Gino Terrado
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

 

Apr 27, 2010 at 7:33 PM

I am using VS2010 and trying to test the service using the test project.

I enabled the "Enable Deployment" option and because of this the test project was creating a "TEST Result" folder and not copying the resource specific folder to that "Test Result" folder. I Wrote a script to copy that folders and it start giving me the language specific resources.

Thanks for all your help.

 

Apr 27, 2010 at 11:39 PM

Hey timirp, I believe you can copy files to the Test Result folder without having to write a script.  You can make use of the DeploymentItem attribute in your test method or add those files you want in the Deployment tab by editing the test run configuration.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Apr 29, 2010 at 4:32 PM

I added the complete folders as a deployment item and its working now. Now i am moving to Entrprise Library 5.

Apr 29, 2010 at 7:39 PM

I deployed my service to server and trying to include the config file to main web.config. The specified file path for config as bellow. But it did not worked. When i specified the actual path e.g. (C:\Service....) it is working. Is there any reason?

filePath="PurchaseOrder.Contract.Validation.config"

 

 

 

 

Apr 30, 2010 at 2:38 AM
Edited Apr 30, 2010 at 2:44 AM

Is it from a fileconfigurationsource? 

If yes, how are you using this fileconfigurationsource, are you creating an instance of FileConfigurationSource in your code and passing it to call to validations?

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com