C# 如何在ASP.NET上使用各种特定于区域性的资源文件
我有一个网站,目前使用EN-US,我也有法语资源文件。我需要编写什么代码才能使应用程序使用资源文件的法语版本 该站点是一个使用.NET的商务服务器和共享点站点C# 如何在ASP.NET上使用各种特定于区域性的资源文件,c#,asp.net,C#,Asp.net,我有一个网站,目前使用EN-US,我也有法语资源文件。我需要编写什么代码才能使应用程序使用资源文件的法语版本 该站点是一个使用.NET的商务服务器和共享点站点 任何代码示例都很好。您有两个选择。选项一是在应用程序级别。您可以在web.config的system.web部分执行此操作: <globalization culture="fr-FR" uiCulture="fr-FR" /> 请参阅更多信息。< P>我认为主要资源文件的特性是根据URL中通过代码指定的文化来检索本地化字符
任何代码示例都很好。您有两个选择。选项一是在应用程序级别。您可以在web.config的system.web部分执行此操作:
<globalization culture="fr-FR" uiCulture="fr-FR" />
<>请参阅更多信息。< P>我认为主要资源文件的特性是根据URL中通过代码指定的文化来检索本地化字符串的能力,如:
localresourcestring = (String)GetLocalResourceObject("username")
//will retrieve the localized string for username from your resx (according to the resx's name)!
这是一个很好的起点,包括演练等..我会在global.asax文件中的
应用程序\u BeginRequest()
全局事件中设置语言:
protected void Application_BeginRequest()
{
// Get the CultureInfo object that contains the French language specification
CultureInfo frenchCulture = CultureInfo.CreateSpecificCulture("fr-FR");
// Set the language the current thread uses (per-user)
Thread.CurrentThread.CurrentCulture = frenchCulture;
Thread.CurrentThread.CurrentUICulture = frenchCulture;
}
希望能有帮助
localresourcestring = (String)GetLocalResourceObject("username")
//will retrieve the localized string for username from your resx (according to the resx's name)!
protected void Application_BeginRequest()
{
// Get the CultureInfo object that contains the French language specification
CultureInfo frenchCulture = CultureInfo.CreateSpecificCulture("fr-FR");
// Set the language the current thread uses (per-user)
Thread.CurrentThread.CurrentCulture = frenchCulture;
Thread.CurrentThread.CurrentUICulture = frenchCulture;
}