I want to localize / globalize the fields on my Login page. I am using ASP.NET MVC 3 Preview 1 with the razor view engine.
Some background
First of all, i've set my routing and added a localization attribute handler so that I can write http://mysite.com/{lang}/{controller}/{action}/{id}
. Now this works all good. In my Views
folder I've added a Home folder with a corresponding App_LocalResources
so far so good. I can even add language files for different languages such as Index.resx
and Index.sv.resx`.
The problem
Having a file called Account.resx
in the root's App_GlobalResources
I of course imagine I should be able to access that from my pages. In my AccountModel.cs
( which came with the installation / template project ) I have added the following to the LogOnModel
public class LogOnModel
{
[Required]
[Display(Name = "UserName", ResourceType = typeof(Account))]
public string UserName { get; set; }
[Required]
[DataType(DataType.Password)]
[Display(Name = "Password", ResourceType = typeof(Account))]
public string Password { get; set; }
[Display(Name = "RememberMe", ResourceType = typeof(Account))]
public bool RememberMe { get; set; }
}
I have two files in my App_GlobalResource
- Account.resx
- Account.sv.resx
And it does in fact take the text from the english / default file. But when I append /sv/ to my URL or even ensure that the culture is swedish, it doesn't change the language to what is in my `Account.sv.resx
.
An example of what could be in the LogOn.cshtml
<div class="editor-label">
@Html.LabelFor(m => m.UserName)
</div>
Any ideas?