简体   繁体   中英

When setting a culture, should we have 2 cultures or just 1 on the server side?

Currently based on users settings, we are setting the culture info on the server-side (asp.net mvc), is this correct?

ie if they are in the US:

System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");

So if they are spanish speaking we will set that, etc.

Is this correct?

Or should we have only a single culture server side, and then on the UI side change as required?

This is a correct way to do it, when you combine it with localized resources. I have implemented globalization the same way on my website ( vocableman.com ). You can use user browser's preferences to set the right language, that user prefers to use.

EDIT: Maybe I didn't understand you correctly. You should better offer the user an option on the website to easily switch to another language. In ASP.NET MVC you can maintain user's selected language as first part of the relative path - eg example.com/en/Home. This way you can always know that the user has selected a language and can generate urls on the page accordingly. Of course, the first time user visits the root page (eg example.com/) you should guess his preference and redirect him to the version that his browser states as prefered.

在服务器端,一个线程在任何给定时间只服务一个请求,因此在服务器端设置多个文化没有问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM