473,714 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve the user's browser language

5 New Member
Hi Everyone,

I'm dharyl from Philippines, I had a problem in knowing the user's browser Language. I was asked to have an alert pop up when the user of the site is using other language than "en-us".
I had this code below just to test what language setting should the page read from the user.
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2.     var a = navigator.browserLanguage;
  3.     var b = navigator.userLanguage;
  4.     var c = navigator.systemLanguage;
  5.     alert("browser language");
  6.     alert(a);
  7.     alert("user language");
  8.     alert(b);
  9.     alert("system language");
  10.     alert(c);     
  11. </script>
Expand|Select|Wrap|Line Numbers
  1. navigator.browserLanguage --> en-us
  2. navigator.systemLanguage --> en-us
  3. navigator.userLanguage --> en-us
when I change my browser language from Tools>InternetO ptions>General> Languages
results are the same:
Expand|Select|Wrap|Line Numbers
  1. navigator.browserLanguage --> en-us
  2. navigator.systemLanguage --> en-us
  3. navigator.userLanguage --> en-us
when I change my browser language from
Start>ControlPa nel>Regionaland LanguageOptions >Regional Options tab
the value of userLanguage changes just as what I set:
Expand|Select|Wrap|Line Numbers
  1. navigator.browserLanguage --> en-us
  2. navigator.systemLanguage --> en-us
  3. navigator.userLanguage --> Ja
  4.  
That means navigator.userL anguage is for this one
Start>ControlPa nel>Regionaland LanguageOptions >Regional Options tab

Now my point is how would I get the value of language setting from this one?
Tools>InternetO ptions>General> Languages

Because I guess that's what I need for my task to be done.
Hope you guys can help me on this.


Thanks in advance,
dha
Dec 27 '07 #1
10 6001
acoder
16,027 Recognized Expert Moderator MVP
Hi, welcome to TSDN!

Some or all of these properties are not supported by most browsers. See this link.
Dec 27 '07 #2
dharyl
5 New Member
Hi, welcome to TSDN!

Some or all of these properties are not supported by most browsers. See this link.

Hi acoder,

Thanks for the reply. I think all I need for now is to make it work in IE.
Or are there no more way for my codes to know what browser language the user is using? Coz I really need solution for this problem.


thanks,
dharyl
Dec 28 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
If you want an IE-only solution, you could use ActiveX/vbscript instead. This allows you to access the local settings when the correct security level is enabled.
Dec 28 '07 #4
dharyl
5 New Member
If you want an IE-only solution, you could use ActiveX/vbscript instead. This allows you to access the local settings when the correct security level is enabled.


but I need to do it in JavaScript
Jan 2 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
but I need to do it in JavaScript
Then sorry, but it's not possible.
Jan 2 '08 #6
dharyl
5 New Member
Then sorry, but it's not possible.

Hi acoder,

thanks for your time. if ever I'll be able to find solution for this, I'll send it to you, maybe somebody will need it in the near future.


Thanks for time,

dharyl :)
Jan 3 '08 #7
acoder
16,027 Recognized Expert Moderator MVP
Yes, that's the spirit! You'll probably need a mixture of JScript (IE version of JavaScript) and vbscript or something along those lines. Good luck!
Jan 3 '08 #8
dharyl
5 New Member
hi acoder,


Good news!
I have resolved my issue, but not with the help of JavaScript. I used VB.Net, I created a webpart with MOSS2007, the code was VB.Net.
I used this line of code below to retreive the user's browser language which is being passed to the server using the HTTP header.

HttpContext.Cur rent.requestSer verVariables("H TTP_ACCEPT_LANG UAGE")

Hope this would help someone in the future.



And by the way I had a new issue encountered in one of my pages.
When I use the word search as search term, the page returns error.
Do you have any thoughts on this?


Thanks,

dha
Jan 15 '08 #9
acoder
16,027 Recognized Expert Moderator MVP
Good news!
I have resolved my issue, but not with the help of JavaScript. I used VB.Net, I created a webpart with MOSS2007, the code was VB.Net.
I used this line of code below to retreive the user's browser language which is being passed to the server using the HTTP header.

HttpContext.Cur rent.requestSer verVariables("H TTP_ACCEPT_LANG UAGE")
I'm glad you got it working.
Hope this would help someone in the future.
I'm sure it will. Thanks for posting your solution.

Note that I've changed the thread title to make it easier for others with a similar problem to find this thread.
And by the way I had a new issue encountered in one of my pages.
When I use the word search as search term, the page returns error.
Do you have any thoughts on this?
If it's a JavaScript error, start a new thread for this mentioning the error message.
Jan 15 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
67731
by: Johan den Boer | last post by:
Hi, I am new to php. Is it possible to find out the windows user name in php ? Logon in windows domain with 'user1'. I want to get the username in php in my example : user1. How do you that ? thanks
0
1730
by: Chung Leong | last post by:
My contribution to the comp.lang.php FAQ: ------------------------------------------------------------- Q: How do I retrieve a page from a web site? A: Pass a URL to file() or file_get_contents(). The former returns the contents as an array of lines. The latter returns the same as string. Example: $html = file_get_contents("http://www.cnn.com");
5
11200
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window after having navigated to some page, it doesn't work. It just returns to the start page or says "timeout" etc. This means that I can't read these pages from PHP with $string = file_get_contents('http://some.url/blah/deep/link');
60
7284
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm The detector requires javascript 1.0 to work. This translates to netscape 2.0 and IE 3.0 (although maybe IE 2.0 also works with it)
9
3716
by: Colin Graham | last post by:
hi folks, just wonder if this is possible or is there a better way of doing this. i need to store values in cookies between two forms. the details are added in a popup when this is closed the main form stores these values in hidden fields. at this point xml is built up and submitted to a biztalk server. if there is an error the page is refreshed and the initial values i added via the popup are lost. my idea was to store these as...
5
1466
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi! I have an application that retrieves its settings from an Apache server XML file. The application bombs at this line for one user only: m_XMLReader = new XmlTextReader(configFileURL); Everybody else who logs into the laptop is able to use the application with no problems. Is it a permission problem ? If so, what kind of permissions are we talking about. I am very puzzled. The user is in another country and I can not
4
2078
by: kang jia | last post by:
hi i am doing mailinglist currently. the code in my first page is like this : : <html> <head> <link rel="stylesheet" type="text/css" href="gallery.css" /> <script language="JavaScript"> <!--
7
1180
by: microgolf | last post by:
Hey, i have a question. i'm about to run an multilangual (if that even is a word) site and i would like to adjust the language of the site depending on what region the user lives... is there a way to know? thanks in advance, microgolf
4
1878
by: Archanak | last post by:
Hi, I have table like this: select * from sampletest; | title | description ...
0
8711
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6636
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5948
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4726
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2112
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.