ASP.NET MVC 应用程序中的多种语言? [英] Multiple languages in an ASP.NET MVC application?

查看:27
本文介绍了ASP.NET MVC 应用程序中的多种语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 ASP.NET MVC 应用程序中支持多种语言的界面的最佳方式是什么?我见过人们将资源文件用于其他应用程序.这仍然是最好的方法吗?

What is the best way to support multiple languages for the interface in an ASP.NET MVC application? I've seen people use resource files for other applications. Is this still the best way?

推荐答案

如果您使用默认视图引擎,则本地资源在视图中工作.但是,如果您需要在控制器操作中获取资源字符串,则无法获取本地资源,而必须使用全局资源.

If you're using the default view engines, then local resources work in the views. However, if you need to grab resource strings within a controller action, you can't get local resources, and have to use global resources.

考虑到这一点是有道理的,因为本地资源是 aspx 页面的本地资源,而在控制器中,您甚至还没有选择视图.

This makes sense when you think about it because local resources are local to an aspx page and in the controller, you haven't even selected your view.

这篇关于ASP.NET MVC 应用程序中的多种语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆