国际化与ASP.Net MVC3(适用于所有浏览用户选择preferred语言一次) [英] Internationalization with ASP.Net MVC3(User Select Preferred language once for all View)

查看:190
本文介绍了国际化与ASP.Net MVC3(适用于所有浏览用户选择preferred语言一次)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用户为整个应用程序选择preferred语言一次。建议我最简便的步骤。

使得用户选择preferred语言只有一次只需登录,然后将所有的应用程序与选择的文化渲染视图之后。

我发现服用点相关 rel=\"nofollow\">

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


因为我在国际化是新我没有得到正确。

我创建了做工精细用浏览器的具体文化一个示例应用程序,但在这里,我希望用户选择preferred语言。


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(适用于所有浏览用户选择preferred语言一次)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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