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 国际化(用户选择首选语言一次查看)
基础教程推荐
- C# 从 List<List<int>> 中删除重 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
