Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Language change!

Posted on 2010-08-21
4
Medium Priority
?
548 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
Suggested Courses

782 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