ASP.NET MVC 视图全球化
我正在考虑全球化我在 ASP.NET MVC 中开发的应用程序。
我当前正在使用资源文件来存储向用户呈现的消息(即,当我将某些内容保存到数据库时,并向用户显示消息“正确保存的内容”),该文本存储在资源文件中,以便我可以轻松地将消息本地化为另一种语言。
在整个视图中执行此操作?
我现在的问题是如何 本地化视图的最佳实践?我在这里查看:
那篇文章中的方法似乎是一种有趣的方法,但我想知道为每种语言维护单独的视图有多么容易
注意:我通常没有在 ASP.NET 中进行太多的全球化或本地化,因此可能有一些来自非语言的最佳实践。我所缺少的-mvc世界。
I am looking at globalizing an application that I have developed in asp.net mvc.
I am currently using resource files to store messages that I present to the user (i.e., when I save something to the database, and the user is shown the message "The whatever was correctly saved", that text is stored in a resource file so that I can easily localize the message for another language.
The question I have is how to do this in a view as a whole? Right now, I've got some views that are mostly HTML with some small amount of presentation logic.
What is the best practice for localizing a view? I've taken a look here:
The approach in that post seems like an interesting way to go, but I wonder how easy it will be to maintain separate views for every language.
NOTE: I have not done much globalization or localization in asp.net generally, so there may be some best practices from the non-mvc world that I am missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我们的新 MVC 应用程序 和我们的解决方案遇到了同样的问题在这里。 维持不同的观点可能是一项艰苦的工作,但用不同的语言维持相同的观点似乎同样困难,我们认为维持整体观点将给我们更多的权力,这是为亚洲国家发布版本所需要的。
希望它对您有帮助。
We ran into the same problem with our new MVC application and our solution is here. Maintaining separate views could be hard work, but maintaining the same view with different languages appears to be just as difficult, we decided that maintaining the whole view would give us more power, which would be required to make a release for Asian countries.
Hopefully it helps you.
对每个视图文件夹使用 App_LocalResources,并为该文件夹和每种区域性中的每个视图放置资源。
更多信息请参见此处。
Use an App_LocalResources for each view folder and place resources for each view in the folder and each culture.
More info here.
您可以尝试将路线设置为类似:
然后将本地化作为操作的参数,就像 id 是参数一样。
You could try setting up your routes to be something like:
and then have localization as a parameter to your actions, just as id is a parameter.