473,490 Members | 2,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

getLocale equivalent in javascript

8 New Member
Hi,

Does anybody know how to get client locale in javascript. I know vbscript GetLocale function but I am searching its equivalent in javascript.

Some sites have mentioned using getLocale(request). Here request is HTTPRequest object but I can not make HTTP Request object in javascript. Please tell me how to use it.

Thanks
Sanjivani
Apr 2 '08 #1
10 12218
acoder
16,027 Recognized Expert Moderator MVP
With JavaScript, some browsers support browser/user/systemLanguage/language properties of the Navigator object. See this example.
Apr 2 '08 #2
SanjivaniPant
8 New Member
With JavaScript, some browsers support browser/user/systemLanguage/language properties of the Navigator object. See this example.
Hi.

Thanks for your reply.. I want client machine locale, not browser langauge. navigotor will give me browser language. If I use sysemlangauge then it works in IE but not in mozilla :(

How about making http request and getting detail from http request header? At present I am searching for how to read http request header in javascript. If you know, please share your knowledge.

~Sanjivani
Apr 3 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
You can use just navigator.language in Mozilla/Firefox.

When you make an http request, would that not be for the server?
Apr 3 '08 #4
SanjivaniPant
8 New Member
You can use just navigator.language in Mozilla/Firefox.

When you make an http request, would that not be for the server?

We can make request from javascript. Have a look onto following link.
http://www.jibbering.com/2002/4/httprequest.html

I could manage to make http request but I could not see system language in response :(

navigator.language will give me broswer langauge or client system language?

Thanks
Sanjivani
Apr 3 '08 #5
SanjivaniPant
8 New Member
navigator.language in mozilla always returns en-US

¬Sanjivani
Apr 3 '08 #6
acoder
16,027 Recognized Expert Moderator MVP
Give an example of what you want returned.
Apr 3 '08 #7
SanjivaniPant
8 New Member
Give an example of what you want returned.
I want to know what is the language set in regional setting on client machine. If client machine has UK regional setting then I want to know that even browser usess US. So I want javascript code for this which should run on mozilla, IE, Safari, Opera.

¬Sanjivani
Apr 3 '08 #8
acoder
16,027 Recognized Expert Moderator MVP
I don't think there's a cross-browser way to get this information using JavaScript, but I could be be proved wrong.

The http request would be to the server, not the client.
Apr 3 '08 #9
SanjivaniPant
8 New Member
I don't think there's a cross-browser way to get this information using JavaScript, but I could be be proved wrong.

The http request would be to the server, not the client.
Right, but request will be from client to server. So we can make XMLHTTPRequest object in javascript for a dummy page. But Only thing I could not figure out is , how to read request header.

Expand|Select|Wrap|Line Numbers
  1.  var xmlhttp=false;
  2. if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  3.     try {
  4.         xmlhttp = new XMLHttpRequest();
  5.     } catch (e) {
  6.         xmlhttp=false;
  7.     }
  8. }
  9. if (!xmlhttp && window.createRequest) {
  10.     try {
  11.         xmlhttp = window.createRequest();
  12.     } catch (e) {
  13.         xmlhttp=false;
  14.     }
  15. }
  16. xmlhttp.open("HEAD", "ReturnHeader.htm",true);
  17.  xmlhttp.onreadystatechange=function() {
  18.   if (xmlhttp.readyState==4) {
  19.    //alert(xmlhttp.getRequestHeader(0));
  20. //Here we have to write code of getting request header, but how? gerRquestHeader method is failing here
  21.   }
  22.  }
  23.  xmlhttp.send(null)
Apr 3 '08 #10
acoder
16,027 Recognized Expert Moderator MVP
I don't think you can get the request header. You can get the response header, but that's probably not much use for you here.
Apr 3 '08 #11

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

Similar topics

2
3312
by: Benoît Dejean | last post by:
here are my locales benoit@athlon >> locale LANG=fr_FR.UTF-8 LC_CTYPE="fr_FR.UTF-8" LC_NUMERIC="fr_FR.UTF-8" LC_TIME="fr_FR.UTF-8" LC_COLLATE="fr_FR.UTF-8" LC_MONETARY="fr_FR.UTF-8"
2
3265
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
22
38501
by: Weston C | last post by:
I know of course that you can use <script src=""></script> in an HTML document to include javascript code you don't want to spill all over the page. I'm wondering if there's a way to include...
2
6191
by: Sergio Otoya | last post by:
Hi all, I have a potentially simple question... I need to keep the value of a field between form posts? I was thinking of using the equivalent of Request.Form("Field1") in javascript to set...
7
3691
by: divya | last post by:
What is an equivalent TimeSerial() function of VBscript in the Java Script?? I have two variables hour and minutes. Timeserial(hour,minutes) returns the time hour : minutes. But I want to do...
2
3487
by: McKirahan | last post by:
Can someone show me the JavaScript equivalent to the following VBScript? Thanks in advance. Randomize For i = 0 to 15 intRnd = Int((16 * Rnd) + 1) Next Perhaps the follwoing is a start?
20
2255
by: shapper | last post by:
Hello, How to create a namespace in Javascript containing two methods? And how to access those methods? Thanks, Miguel
2
1095
by: Nathan Sokalski | last post by:
I have the following script that I am using to test some JavaScript RegExp code: function RE() { var testing1=new RegExp("*"); var testing2=new RegExp("{0,}"); var testing3=new RegExp("+");...
4
2446
by: Berco Beute | last post by:
I wonder what it would take to implement Python in JavaScript so it can run on those fancy new JavaScript VM's such as Chrome's V8 or Firefox' tracemonkey. Much the same as Python implementations...
0
6967
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...
0
7142
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,...
0
7181
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...
1
4875
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...
0
4565
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...
0
3078
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
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...

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.