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.resxandLocalizedText.resx -
In both files I have a value called ‘
InstitutionTitle‘ -
In
LocalizedText.en-us.resxthe value is ‘Institution‘ and in theLocalizedText.resxthe value is ‘Instelling‘ -
In my
.aspxfile I have the following label:<asp:Label ID="lblInstitution" runat="server" Text="<%$ Resources:LocalizedText, InstitutionTitle %>" />
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"]);).
What’s the issue and how can I fix it?
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.
You can do this either programmatically or declaratively on your page (Culture and UICulture attributes of the <%@Page %> directive).
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’.
Check this page for details.