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:
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
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
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
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"))
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
(querystring is only for passing values with a [get]-form)
LN
LN
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have you looked into the folowing?
http://msdn.microsoft.com/en-us/library/system.web.httprequest.userlanguages.aspx
greets,
LN