Get Preferred Culture Info / Language - C#, ASP.NET
Asked Answered
S

3

7

I am trying to get the users preferred language. I see all kinds of articles on how to set it, but they assume that the user is telling it which language to select (like in a dropdownlist).

In Firefox under Tools > Options > Content > Languages > Choose you can select which languages you prefer and choose their order. I want to be able to access that list, or at least the preferred language in the C# codebehind. How do I go about this? Is this possible?

Everything I have tried always returns en-US, no matter whats in the list.

Senghor answered 1/7, 2010 at 22:29 Comment(0)
B
11

I believe what your after is this

Request.UserLanguages

From the documentation

"Gets a sorted string array of client languages preferences.

Bernhard answered 1/7, 2010 at 22:54 Comment(0)
I
0

I think the browser sends this in the Accept-Language header field, as documented by W3c. However, I am not sure how to access that from ASP.net.

Interdepartmental answered 1/7, 2010 at 22:50 Comment(0)
R
0
Dim userLocale
userLocale=Request.ServerVariables("HTTP_ACCEPT_LANGUAGE")

Dim languages
languages = Split(userLocale, ",", -1)
Rascal answered 23/7, 2010 at 17:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.