Localization & Globalization in asp.net mvc 2.0
I know there have been a couple postings on this topic already but I am still confused.
http://www.codeproject.com/KB/aspnet/Localizing_ASP_NET_MVC.aspx?msg=3189952#xx3189952xx
This one seems pretty simple but some people stated that it does not make use of the App_LocalResources folder.
So I am not sure what the difference between these folders are and why you should be using both.
On the flip side this posting seems pretty long and has quite a bit of code to make it change languages.
http://adamyan.blogspot.com/2010/02/aspnet-mvc-2-localization-complete.html
So I am not sure which one is better. The first one is what I expected the code to be but I am not sure if it is because you given the user the choice to choose their language(opposed to using auto or hard 开发者_如何学Pythoncoded value) that the code just swells up and is so long.
Both approaches are basically the same, since the resource files generate public classes with properties returning the strings.
The first use one global resource for all the strings (App_GlobalResources
), and the second one explains how do separate the resource for different views.
In my opinion a global resources are better for MVC apps since you can reuse them in the model and in the views, but YMMV.
精彩评论