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
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:
name.language.resx
name.language-culture.resx
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?
lax4u
Participant
1592 Points
902 Posts
How to set resource strings in resx file
May 09, 2012 05:00 PM|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))]
[DataMember]
public string Name
{
get;
set;
}
lax4u
Participant
1592 Points
902 Posts
Re: How to set resource strings in resx file
May 09, 2012 06:58 PM|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:
name.language.resx
name.language-culture.resx
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?
Tim Cadieux
Participant
966 Points
317 Posts
Re: How to set resource strings in resx file
Jul 26, 2012 05:40 PM|LINK
Thorough tutorial here
localization
***
Mark the replies as Answers if they answered your question.