我有一个Default.aspx
文件,我在其中获取本地化的值:
Default.aspx :
<asp:Localize meta:resourcekey="lblTitle" runat="server">Welcome</asp:Localize>
然后,我创建一个匹配的后备资源文件:
Default.aspx.resx :
lblTitle.Text Welcome to Stackoverflow Localized
那行得通:
现在,我想创建一个法国本地化版本:
Default.aspx.fr.resx :
lblTitle.Text Bienvenue Stackoverflow
然后我将浏览器更改为发送法语语言环境:
(它的作用):
GET http://stackoverflow.com/ HTTP/1.1
Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*
Accept-Language: fr-CH,qps-ploc;q=0.5
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Host: stackoverflow.com
只是它不起作用:
我正在关注Microsoft says:
.NET为什么不执行.NET应该做什么?
更新:
从MSDN:
我如何获得ASP.NET将页面的
UICulture
和Culture
属性设置为浏览器传递的语言和区域性值?来自 How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization:
最佳答案
尝试在.aspx文件的UICulture="auto"
伪指令中设置Culture="auto"
和@ Page
。
How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization
或者,您可以在web.config中完成相同的操作,除了它适用于每个页面:
<system.web>
<globalization uiCulture="auto" culture="auto" />
</system.web>