Solved

Language change!

Posted on 2010-08-21
4
546 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:jonathangodwin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Navecha
ID: 33490913
hello,

have you looked into the folowing?

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

greets,

LN
0
 
LVL 1

Expert Comment

by:Navecha
ID: 33490917
(querystring is only for passing values with a [get]-form)

LN
0
 
LVL 1

Author Comment

by:jonathangodwin
ID: 33490962
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
0
 
LVL 1

Accepted Solution

by:
jonathangodwin earned 0 total points
ID: 33491025
Dim lang As String = Request.UserLanguages(0).ToString
if lang = "it" Then
SideBar3.CssClass = "<your css class goes here>"
End If

is how to do it for future reference for people
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question