Internationalization with ASP.Net MVC3(User Select Preferred language once for all View)(使用 ASP.Net MVC3 国际化(用户选择首选语言一次查看))
问题描述
我希望用户为整个应用选择一次首选语言.建议我最简单的步骤.
这样用户在登录后只选择一次首选语言,然后所有应用程序的视图都以所选文化呈现.
我发现了一些相关的这里
I want user to select preferred language once for the whole app. suggest me the easiest possible steps.
Such that user select preferred language only once just after login and then all app's view rendered with selected culture.
I found somehting related here
因为我是国际化的新手,所以我没有正确理解它.
我创建了一个示例应用程序,它可以在浏览器特定的文化中正常工作,但在这里我希望用户选择首选语言.
Because i am new in Internationalization i am not getting it properly.
I created a sample application which is working fine with browser specific Culture but here i want user to select preferred language.
推荐答案
通常,.NET 将使用与用户最匹配的 CultureSetting,然后确定用于全球化的适当资源文件.
Typically, .NET will use the CultureSetting that best matches the user and then determines the appropriate resource file to use for globalization.
一旦您保存"了用户适当的文化,就会出现在数据库、会话或 cookie 中.
Once you have "saved" the users appropriate culture be in a database, session, or cookie.
我所做的是将线程更改为适当的语言:
What I do is change the thread to the appropriate language:
var language = "fr"; // Pull from your "saved" location (database, session, cookie, etc.)
// This changes UI only
Thread.CurrentThread.CurrentUICulture = new CultureInfo(language);
// This changes how number, date formatting is handled
Thread.CurrentThread.CurrentCulture = new CultureInfo(language);
希望有帮助!
这篇关于使用 ASP.Net MVC3 国际化(用户选择首选语言一次查看)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 ASP.Net MVC3 国际化(用户选择首选语言一次查看)
基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
