I've created a Class Library that uses the Validation Application Block on an object that uses a Resource File. I can get it to return the appropriate item from the resource file but I need to add support for additional languages. Currently, the class has properties that resemble the following:
Class Library > Contact.cs
[StringLengthValidator(0, 50, Ruleset = "Contact", Tag = "ContactBestTimeLengthValidator", MessageTemplateResourceName = "ContactBestTimeLengthValidator", MessageTemplateResourceType = typeof(Contact))]
public string BestTime
{
get
{
return bestTime;
}
set
{
bestTime = value;
}
}
And a resource file that has an item for ContactBestTimeLengthValidator (Class Library > Resources > Contact.resx)
If I add something like Class Library > Resources > Contact.fr-ca.resx with the appropriate values and I'm unable to access these files using a mechanism such as ResourceManager. Example:
CultureInfo cultureInfo = CultureInfo.GetCultureInfoByIetfLanguageTag("fr-ca");
ResourceManager resourceManager = new ResourceManager("Contact", typeof(Contact).Assembly);
ResourceSet resourceSet = resourceManager.GetResourceSet(cultureInfo, true, false);
string value = resourceSet.GetString("ContactBestTimeLengthValidator", true);
And preferably the resource files should be outside of the assembly so they can be modified without having to recompile the application. Everywhere I've looked points to this article: http://www.pnpguidance.net/Post/ValidationApplicationBlockMessageTemplateTokensResourceFiles.aspx but it doesn't completely meet my needs.
Any suggestions?