如何在MVC5中将文化设置为全局 [英] How to set culture as globally in mvc5

查看:98
本文介绍了如何在MVC5中将文化设置为全局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用资源文件切换在mvc5中构建的Web应用程序中的语言

I am using resource files to switch languages in my web application which is build in mvc5

在索引文件中,它读取我设置的文化值.

In index files its reading the culture value which i set.

我正在从layout.cshtml调用设置区域性方法,并使用以下代码调用其值.

I am calling the set culture method from layout.cshtml and calling its value with the following code.

@{
Layout = "~/Views/Shared/_Layout.cshtml";

if (!Request["dropdown"].IsEmpty())
{
    Culture = UICulture = Request["dropdown"];
}

}

在索引页面中,语言已正确加载,但是从那里进入下一页时,它将加载默认语言德语,但资源仅从英语资源文件中读取.

in index page the language is loading correctly but when from there when i go to the next page its loading the default language German but the resources reading from English resource file only.

请帮助我这个..任何人

Please help me on this..anybody

推荐答案

web.config中,我在内部注释了以下行,对我来说很好用.

In web.config I commented the following line inside and it worked fine for me.

<configuration>
   <system.web>
    <globalization culture="en-US" uiCulture="en-US" />  <!-- this only -->
   </system.web>
</configuration>

这篇关于如何在MVC5中将文化设置为全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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