How to change my computer's cultureInfo

坚强是说给别人听的谎言 提交于 2019-12-13 16:48:53

问题


I am running a site on IIS that reads the culture info from Thread.CurrentThread.CurrentCulture. This comes from the System culture info from what I understand. I need it set to a certain value and I've been unable to change it at the OS level.

My windows 7 computer was initially set up in the en-GB culture, and I now need to switch it to en-US. I have changed it in the Region and Language control panel. In the Formats tab, The Format is English (United States), In the Location tab, the current location is United States, in the Administrative tab, Current language for non-Unicode programs is English (United States). After restart, the values all read correct in the windows UI.

I've restarted my computer after those changes, I've cleared my local DNS (don't know if that matters), I've restarted IIS, I've recycled the app pool, but it still reads as en-GB.

Is there anything else I need to do to update this cultureInfo?


回答1:


ASP.NET itslef has configuration for that task. Culture could be set (many ways) inside a web.config file in the system.web section. The below snippet shows, how could be en-US culture forced

<globalization 
    enableClientBasedCulture="false" 
    uiCulture="en-US" 
    culture="en-US" />

If application is ready to accept the culture from the client (browser), settings should be

<globalization 
    enableClientBasedCulture="true" 
    uiCulture="auto" 
    culture="auto" />

The above setting will take a Language selected in client browser (e.g. cs-CZ in my case). If none is defined then system settings will be used. Final snippet shows, how to allow client to set and send intended culture, but in case that no Language is pre-selected, override the system setting with some other default value en-US

<globalization 
    enableClientBasedCulture="true" 
    uiCulture="auto:en-US" 
    culture="auto:en-US" />


来源:https://stackoverflow.com/questions/12984166/how-to-change-my-computers-cultureinfo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!