views:

862

answers:

2

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 and LocalizedText.resx
  • In both files I have a value called 'InstitutionTitle'
  • In LocalizedText.en-us.resx the value is 'Institution' and in the LocalizedText.resx the value is 'Instelling'
  • In my .aspx file 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?

A: 

@martijn:

  1. check the browsers caching settings. Caching should be off all the time when developing.

  2. Install Firebug (FF) and Fiddler(IE) to see what's being transfered over the wire.

Hope this helps...

signed,

A fellow countryman

norbertB
Fellow countryman :) The cach wasn't the problem. I will try point 2 now.
Martijn
@norbertB: Just a side question - How does Firebug enable one to sniff out HTTP headers?
Cerebrus
@NorbertB: How do i have to use Firebug to see what's happening? I don't know how to use it..
Martijn
@NorbertB: Fiddler doesn't capture localhost :( It's captures when i surf to google, but when i go to my localhost, it doesn't.
Martijn
+2  A: 

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".

// web.config:
<globalization enableClientBasedCulture="true" ...>

// page/masterpage:
<%@ Page ... Culture="auto" UICulture="auto" %>

Check this page for details.

M4N
I added this line in my web.config within the configuration, system.web tag. But no success. I still see the dutch text and have no error message
Martijn
try adding this to your page directive "<%@ Page ... Culture="auto" UICulture="auto" %>"
M4N
That work , thnx. When I add that to my masterpage, does that affect all the content pages? And why is the setting in my web.config not working?
Martijn
Yes, when set on the masterpage, it applies to all pages which use that masterpage.
M4N
Thnx. And can you explain why the setting wasn't working in my web.config file? I have it commented out now and it is still working
Martijn
It seems the web.config setting (enableClientBasedCulture) is not used. See this page: http://msdn.microsoft.com/en-us/library/hy4kkhe0.aspx
M4N