Tec*_*hNo 5 c# asp.net razor visual-studio-2013 asp.net-mvc-5
我正在使用资源文件在我的Web应用程序中切换语言,该应用程序是在mvc5中构建的
在索引文件中,它读取我设置的文化值.
我从layout.cshtml调用set culture方法并使用以下代码调用其值.
@{
Layout = "~/Views/Shared/_Layout.cshtml";
if (!Request["dropdown"].IsEmpty())
{
Culture = UICulture = Request["dropdown"];
}
Run Code Online (Sandbox Code Playgroud)
}
在索引页面中语言正确加载,但是当我从那里进入下一页时,它加载默认语言德语,但资源仅从英语资源文件中读取.
请帮帮我..这个人
Dud*_*udi 15
对于全局设置,我建议您将以下行添加到global.asax.cs文件中:(在此示例中,文化设置为以色列希伯来文)
protected void Application_Start()
{
//The culture value determines the results of culture-dependent functions, such as the date, number, and currency (NIS symbol)
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = new System.Globalization.CultureInfo("he-il");
//System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = new System.Globalization.CultureInfo("he-il");
}
Run Code Online (Sandbox Code Playgroud)
Tec*_*hNo 12
在web.config我评论了以下内容,它对我来说很好.
<configuration>
<system.web>
<globalization culture="en-US" uiCulture="en-US" /> <!-- this only -->
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15665 次 |
| 最近记录: |