Localization & Globalization in asp.net mvc 2.0

限于喜欢 提交于 2019-12-25 16:59:19

问题


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 coded value) that the code just swells up and is so long.


回答1:


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.



来源:https://stackoverflow.com/questions/4660688/localization-globalization-in-asp-net-mvc-2-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!