I just started using explicit resource files. I performed these steps:
我刚开始使用显式资源文件。我执行了以下步骤:
- In the root create the folder:
App_GlobalResources
- Add two resx files:
LocalizedText.en-us.resx
andLocalizedText.resx
- In both files I have a value called '
InstitutionTitle
' - In
LocalizedText.en-us.resx
the value is 'Institution
' and in theLocalizedText.resx
the value is 'Instelling
' -
In my
.aspx
file I have the following label:在我的.aspx文件中,我有以下标签:
<asp:Label ID="lblInstitution" runat="server" Text="<%$ Resources:LocalizedText, InstitutionTitle %>" />
在根目录中创建文件夹:App_GlobalResources
添加两个resx文件:LocalizedText.en-us.resx和LocalizedText.resx
在这两个文件中,我有一个名为'InstitutionTitle'的值
在LocalizedText.en-us.resx中,值为“Institution”,在LocalizedText.resx中,值为“Instelling”
When I run this page, I always get the dutch version. Whether I set the language in my browser (FF and IE7) or not, I always get the dutch version. When I request the browsers' language I get en-us
(using: Response.Write(Request.Headers["Accept-Language"]);
).
当我运行这个页面时,我总是得到荷兰语版本。无论我是否在我的浏览器(FF和IE7)中设置语言,我总是得到荷兰语版本。当我请求浏览器的语言时,我得到了en-us(使用:Response.Write(Request.Headers [“Accept-Language”]);)。
What's the issue and how can I fix it?
问题是什么,我该如何解决?
2 个解决方案
#1
Setting the language preferences in the browser is not enough. You have to make sure that the current thread's Culture and UICulture properties are set accordingly in ASP.NET.
在浏览器中设置语言首选项是不够的。您必须确保在ASP.NET中相应地设置当前线程的Culture和UICulture属性。
You can do this either programmatically or declaratively on your page (Culture and UICulture attributes of the <%@Page %> directive).
您可以在页面上以编程方式或声明方式执行此操作(<%@ Page%>指令的Culture和UICulture属性)。
Or you can let ASP.NET set them automatically by setting the web.config entry shown below and setting the Culture/UICulture properties of the page/masterpage to "auto".
或者,您可以通过设置下面显示的web.config条目并将页面/母版页的Culture / UICulture属性设置为“auto”来让ASP.NET自动设置它们。
// web.config:
<globalization enableClientBasedCulture="true" ...>
// page/masterpage:
<%@ Page ... Culture="auto" UICulture="auto" %>
Check this page for details.
查看此页面了解详细信息。
#2
@martijn:
-
check the browsers caching settings. Caching should be off all the time when developing.
检查浏览器缓存设置。在开发时,缓存应该一直处于关闭状态。
-
Install Firebug (FF) and Fiddler(IE) to see what's being transfered over the wire.
安装Firebug(FF)和Fiddler(IE)以查看通过电线传输的内容。
Hope this helps...
希望这可以帮助...
signed,
A fellow countryman
同乡
#1
Setting the language preferences in the browser is not enough. You have to make sure that the current thread's Culture and UICulture properties are set accordingly in ASP.NET.
在浏览器中设置语言首选项是不够的。您必须确保在ASP.NET中相应地设置当前线程的Culture和UICulture属性。
You can do this either programmatically or declaratively on your page (Culture and UICulture attributes of the <%@Page %> directive).
您可以在页面上以编程方式或声明方式执行此操作(<%@ Page%>指令的Culture和UICulture属性)。
Or you can let ASP.NET set them automatically by setting the web.config entry shown below and setting the Culture/UICulture properties of the page/masterpage to "auto".
或者,您可以通过设置下面显示的web.config条目并将页面/母版页的Culture / UICulture属性设置为“auto”来让ASP.NET自动设置它们。
// web.config:
<globalization enableClientBasedCulture="true" ...>
// page/masterpage:
<%@ Page ... Culture="auto" UICulture="auto" %>
Check this page for details.
查看此页面了解详细信息。
#2
@martijn:
-
check the browsers caching settings. Caching should be off all the time when developing.
检查浏览器缓存设置。在开发时,缓存应该一直处于关闭状态。
-
Install Firebug (FF) and Fiddler(IE) to see what's being transfered over the wire.
安装Firebug(FF)和Fiddler(IE)以查看通过电线传输的内容。
Hope this helps...
希望这可以帮助...
signed,
A fellow countryman
同乡