Link to home
Start Free TrialLog in
Avatar of jonathangodwin
jonathangodwin

asked on

Language change!

Hi all,

I'm trying to get my application to detect what language the browser is set to, then make changes accordingly. So far I have:

Dim lang As String
lang = Request.QueryString("Language")
If lang = "it" then
Sidebar3.CssStyle = "sidebar h2"
End if

Open in new window


this didn't work, so I played around with trying 'language' instead of 'Language', and 'it-IT" instead of "it" but nothing seems to work.

Then I thought that maybe the string 'lang' wasn't working as it should, so I tried a

Response.Write(Request.QueryString("Language"))

Open in new window


nothing was written at all. As you can see in the first 'code' - I'm trying to change the CSS class of sidebar3 (an asp label) if the browser language is set to Italian. I've also tried doing a Select Case - this yields the same result, nothing.

I'm using IE8 and Chrome for testing, no variations on results for either.

Any help will be appreciated!

Jonathan
Avatar of Navecha
Navecha

hello,

have you looked into the folowing?

http://msdn.microsoft.com/en-us/library/system.web.httprequest.userlanguages.aspx

greets,

LN
(querystring is only for passing values with a [get]-form)

LN
Avatar of jonathangodwin

ASKER

Oh ok, so what would be the best way for me to achieve the objective in my original post? I tried:

Dim userLang() As String
        Dim count As Integer

        userLang = Request.UserLanguages
        For count = 0 To userLang.GetUpperBound(0)
            Response.Write("User Language: " & CStr(userLang(count)) & "<br>")
        Next count

which returns:

User Language: en-GB
User Language: it;q=0.8
User Language: en-US;q=0.6
User Language: en;q=0.4

but what can I do to isolate one of the above in an If statement?

Thanks,

Jonathan
ASKER CERTIFIED SOLUTION
Avatar of jonathangodwin
jonathangodwin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial