Last post Jul 26, 2012 05:40 PM by Tim Cadieux
May 09, 2012 05:00 PM|lax4u|LINK
I’m validating my WCF request object’s parameter using DataAnnotation. This is working fine and no problems there.
I want to store my error messages into resx file. According to my understanding the default resource provider will use the Current thread’s UI culture to determine which resource string to retrieve.
Do I need to name the .resx file in certain way so that resource provider will know which file to use for particular culture? If yes, what is the naming convention?
For example, if you see the code below ErrorMessageResourceType is set to ServiceResourceStrings which is the class created by .Net for .resx file, now if I have one more .resx file for different language say “es-MX”, then it will have different class name.
I don’t see the .resx file itself stored any culture code
[Required(ErrorMessageResourceName = "NameRequired", ErrorMessageResourceType = typeof(ServiceResourceStrings))]
public string Name
May 09, 2012 06:58 PM|lax4u|LINK
so on MSDN http://msdn.microsoft.com/en-us/library/ms247246.aspx it says
In the Name box, type a name for the resource file and then click Add.
Type key names and values for each resource that you need in your application, and then save the file.
To create resource files for additional languages, copy the file in Solution Explorer or in Windows Explorer, and then rename it using one of the following patterns:
For global resource files:
so i setup my file names as "ServiceResourceStrings.resx" and "ServiceResourceStrings.fr-CA.resx" and then just for testing purpose i set my web.config file to <globalization uiCulture="fr-CA"/> but the resource provider
always retreives resources from ServiceResourceStrings.resx, WHY?
Jul 26, 2012 05:40 PM|Tim Cadieux|LINK