如何在ASP.NET中更改应用程序语言?

时间:2021-10-19 04:09:41

I'm developing an application with ASP.NET 3.5 and I have read that the language that the application is shown in is the navigator's language.

我正在使用ASP.NET 3.5开发一个应用程序,我已经读过应用程序显示的语言是导航器的语言。

Is there any way to choose the language of the application programmatically? For example, I want to see the application in English but my Internet Explorer is in Spanish.

有没有办法以编程方式选择应用程序的语言?例如,我想用英语查看应用程序,但我的Internet Explorer是西班牙语。

The language is a user's preference stored in the database, so I need to change the language when the user logs in.

该语言是存储在数据库中的用户首选项,因此我需要在用户登录时更改语言。

4 个解决方案

#1


You can use the CultureInfo class to set the culture for your executing environment.

您可以使用CultureInfo类为执行环境设置区域性。

CultureInfo ci = new CultureInfo("en-US", false);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

#2


Are you asking how to change your browser's accept language? See http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx for instructions for IE 7 and IE 8. The section you want is "To add a language to Internet Explorer"

您是否在询问如何更改浏览器的接受语言?有关IE 7和IE 8的说明,请参阅http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx。您需要的部分是“添加语言到IE浏览器”

#3


You can also set it in web.config:

您也可以在web.config中进行设置:

<configuration>
 <system.web>
  <globalization
    requestencoding="utf-8"
    responseencoding=" utf-8"
    fileencoding=" utf-8"
    culture="en-US"
    uiculture="en-US" />
 </system.web>
</configuration>

Or at the page level:

或者在页面级别:

<%@ Page Culture="en-US" UICulture="en-US" ResponseEncoding="utf-8"%>

#4


You can use this <globalization culture="en-US" uiCulture="en-US"/> in <system.web> section of web.config.

您可以在web.config的 部分中使用此

#1


You can use the CultureInfo class to set the culture for your executing environment.

您可以使用CultureInfo类为执行环境设置区域性。

CultureInfo ci = new CultureInfo("en-US", false);
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

#2


Are you asking how to change your browser's accept language? See http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx for instructions for IE 7 and IE 8. The section you want is "To add a language to Internet Explorer"

您是否在询问如何更改浏览器的接受语言?有关IE 7和IE 8的说明,请参阅http://windowshelp.microsoft.com/Windows/en-US/help/7b4a0825-28e2-4929-82f6-1feac4adb6f31033.mspx。您需要的部分是“添加语言到IE浏览器”

#3


You can also set it in web.config:

您也可以在web.config中进行设置:

<configuration>
 <system.web>
  <globalization
    requestencoding="utf-8"
    responseencoding=" utf-8"
    fileencoding=" utf-8"
    culture="en-US"
    uiculture="en-US" />
 </system.web>
</configuration>

Or at the page level:

或者在页面级别:

<%@ Page Culture="en-US" UICulture="en-US" ResponseEncoding="utf-8"%>

#4


You can use this <globalization culture="en-US" uiCulture="en-US"/> in <system.web> section of web.config.

您可以在web.config的 部分中使用此