The project I am working on supports a number of locales. The solution is based on using some Castle Monorail mechanism. Appropriate controller class is marked as follows:
[Resource("pageResx", "...Controllers.Static")]
Where StaticTemplate is the Controller name prefix and resource file is placed in '..\Resources\Controllers\StaticTemplate*'.
On the other hand StatiController inherits from the BaseController class which is marked as follows:
[LocalizationFilter(RequestStore.Session, "locale")]
So, the locale for the user is stored in the session. And this is it. The final step is NVelocity vm-file where the appropriate resource is taken like this:
$pageResx.Buttons_Download
This way the resource string with ID = 'Buttons_Download' for user with locale='de' is taken from file '..\Resources\Controllers\Static.de.resx'.
However, there is another place in the project where localization is held - constructing emails. The following logic is implemented there:
public class EmailPersonalizer : IEmailPersonalizer
{
...
printJobResourceManager = new ResourceManager("...Resources.PrintJob",
typeof (EmailPersonalizer).Assembly);
public string ToLocalizedString(string resourceId, VendorUser user,
params object[] args)
{
...
var resourceString = printJobResourceManager.GetString(resourceId,
culture);
...
}
...
}
Given values for the parameters the resourceString is evaluated correctly. But...
Here comes the Magic. There is a resource file for brazilian locale. It has suffix 'pt-BR'. There is also portuguese locale, but no appropriate resource file - no 'pt' file. In terms of view pages Monorail gets the localized resource from pt-BR file for pt-user. But the logic which implements the email constructing fails to do the same. Instead is gets the localized string from the basic resource which 'en' is used to be.
I read about the .NET mechanism for mapping resources (http://msdn.microsoft.com/en-us/library/sb6a8618.aspx). But failed to find the description for Monorail's one.
The question is how does Monorail (or whoever) map 'pt' to 'pt-BR'? And what am I supposed to do to implement the same logic outside?
Thanks in advance