1

Quick question that I couldn't find a clear answer on, if I get the CurrentCulture of a thread in an MVC application, is this the culture based on the user's browser/OS, or the culture that is set on the server?

Thanks

NeedACar
  • 921
  • 2
  • 8
  • 27

1 Answers1

3

If you enabled enableClientBasedCulture in your Web.Config:

<system.web>
    <globalization enableClientBasedCulture="true" />
</system.web>

Then client culture will be used, otherwise it will use the server culture.

You can also set a fallback culture in case the client didn't send the AcceptLanguage header, by setting the culture and uiCulture properties as well:

<globalization enableClientBasedCulture="true" culture="en-US" uiCulture="en-US" />

See MSDN

haim770
  • 48,394
  • 7
  • 105
  • 133
  • Weird thing is though, is that when I run my app, even from different browsers (that are set to language = NL, I'm not in the US), it will always give me EN-US as current culture. Even if I get the language from the httpcontext-request userlanguages. – NeedACar Oct 22 '14 at 12:37
  • Can you check the actual `Accept-Language` header value that you're sending? – haim770 Oct 22 '14 at 12:38
  • Regardless of the browser, I get: "en-US,en;q=0.8,nl;q=0.6" – NeedACar Oct 22 '14 at 12:53
  • If you're using Google Chrome, see http://stackoverflow.com/questions/7769061/how-to-add-custom-accept-languages-to-chrome-for-pseudolocalization-testing on how to change your first language to `nl` – haim770 Oct 22 '14 at 13:03