469,643 Members | 2,061 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Locale in JavaScript?

I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes to
the system. So the obvious thing seemed to be to have a look-up table of
latitude and longitude against locale, and then use the locale of the
browser...

But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; Good grief, I can remember when England won the Ashes.
Apr 24 '07 #1
33 18979
Simon Brooke said the following on 4/24/2007 6:13 AM:
I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes to
the system. So the obvious thing seemed to be to have a look-up table of
latitude and longitude against locale, and then use the locale of the
browser...
No, the obvious solution is to ask them where they are in the world and
then show it on the Map.
But going through the documentation I can't find any reliable way of
getting the locale in JavaScript.
There isn't one as the PC itself doesn't even know where it is in the world.
Am I missing something, or is this impossible?
Only way is to ask the user. Otherwise, yes, it is impossible.
If it's impossible, why is it impossible?
It is impossible because it is not possible.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #2
in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
Simon Brooke said the following on 4/24/2007 6:13 AM:
>I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes
to the system. So the obvious thing seemed to be to have a look-up table
of latitude and longitude against locale, and then use the locale of the
browser...

No, the obvious solution is to ask them where they are in the world and
then show it on the Map.
I don't want to ask them; that's interfering with the immediacy of their
experience of the system. It's worse than a click-through page.
>But going through the documentation I can't find any reliable way of
getting the locale in JavaScript.

There isn't one as the PC itself doesn't even know where it is in the
world.
The PC knows its locale, however, and the locale is a good enough
approximation for my purposes.
>Am I missing something, or is this impossible?

Only way is to ask the user. Otherwise, yes, it is impossible.
>If it's impossible, why is it impossible?

It is impossible because it is not possible.
But if I run a Java applet on the same PC, suddenly it's possible. So why
is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to get
the locale. But it seems a baroque way to do it.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; L'etat c'est moi -- Louis XVI
;; I... we... the Government -- Tony Blair
Apr 24 '07 #3
Simon Brooke wrote on 24 apr 2007 in comp.lang.javascript:
in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
>Simon Brooke said the following on 4/24/2007 6:13 AM:
>>If it's impossible, why is it impossible?

It is impossible because it is not possible.

But if I run a Java applet on the same PC, suddenly it's possible. So
why is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to
get the locale. But it seems a baroque way to do it.
It is spelled out for you: You think you know where Randy is located, but
HikksNotAtHome, as he is expecting a nymphomaniac blonde on an island.
..... Sorry, I'm mixing threads.

It is not possible because browser security won't let you access the most
private parts of the client's operating system.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 24 '07 #4
Evertjan. said the following on 4/24/2007 4:43 PM:
Simon Brooke wrote on 24 apr 2007 in comp.lang.javascript:
>in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
>>Simon Brooke said the following on 4/24/2007 6:13 AM:
>>>If it's impossible, why is it impossible?
It is impossible because it is not possible.
But if I run a Java applet on the same PC, suddenly it's possible. So
why is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to
get the locale. But it seems a baroque way to do it.

It is spelled out for you: You think you know where Randy is located, but
HikksNotAtHome, as he is expecting a nymphomaniac blonde on an island.
.... Sorry, I'm mixing threads.

It is not possible because browser security won't let you access the most
private parts of the client's operating system.
It is simpler than that. It is not possible because my location is not
on my PC. Not in the OS or anywhere else. The closest you could get
would be a Time Zone and that will only get you within several thousand
miles (if even that close).

Besides, my laptop travels with me (without changing settings) so the
Time Zone may say Easter Time Zone (US) and I could be in London England.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #5
Simon Brooke said the following on 4/24/2007 1:55 PM:
in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
>Simon Brooke said the following on 4/24/2007 6:13 AM:
>>I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes
to the system. So the obvious thing seemed to be to have a look-up table
of latitude and longitude against locale, and then use the locale of the
browser...
No, the obvious solution is to ask them where they are in the world and
then show it on the Map.

I don't want to ask them; that's interfering with the immediacy of their
experience of the system. It's worse than a click-through page.
Then you have no way of doing what you are wanting to do.
>>But going through the documentation I can't find any reliable way of
getting the locale in JavaScript.
There isn't one as the PC itself doesn't even know where it is in the
world.

The PC knows its locale, however, and the locale is a good enough
approximation for my purposes.
It does? Please, oh please, tell me what PC/OS setting tells you where I
am located - geographically. I don't believe you.
>>Am I missing something, or is this impossible?
Only way is to ask the user. Otherwise, yes, it is impossible.
>>If it's impossible, why is it impossible?
It is impossible because it is not possible.

But if I run a Java applet on the same PC, suddenly it's possible.
No it isn't.
So why is it possible for an applet but not for Javascript?
Because it isn't possible for an Applet to give you my Geographical
location.
What is the architectural choice being made here, and what is it being made for?
What choice? You have no way of knowing where I am short of asking me.
Actually that may be the solution - run a single-pixel applet just to get
the locale. But it seems a baroque way to do it.
First you have to prove you can do it. I will even be your guinea pig.
Post a URL to a page that will tell me my geographical location without
asking me.

IP Address? Nope. Mine will tell you that I am in New York City, New
York in the USA and I could be anywhere from NYC to Bangkok Thailand and
it will tell you the same thing.

Time Zone? See above.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #6
Randy Webb said the following on 4/24/2007 5:40 PM:

<snip>
Besides, my laptop travels with me (without changing settings) so the
Time Zone may say Easter Time Zone (US) and I could be in London England.
Now Easter Time Zone would be cool even if my OS does indeed say
Eastern. Sheesh I should proof read sometimes.

That blonde showed up though, she liked women better than men though. Oh
well :)

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 24 '07 #7
In comp.lang.javascript message <lr************@gododdin.internal.jasmin
e.org.uk>, Tue, 24 Apr 2007 11:13:41, Simon Brooke
<si***@jasmine.org.ukposted:
>I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes to
the system. So the obvious thing seemed to be to have a look-up table of
latitude and longitude against locale, and then use the locale of the
browser...

But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?
Standards do not call for it, and it should be easy enough to ask if not
known, store it in a cookie, and have a means of changing the setting.

Until all PCs include Galileo or similar, it's not safe to assume that
the locale setting of the PC matches its geographical whereabouts.

I posses a watch, which is easily enough adjusted by an integer number
of hours or minutes; if I were to take a PC for a trip abroad, I would
use my watch to tell the local time and leave the PC set for UK.

In places which have Summer Time, and when the PC is localised for such
a place, one can tell the Hemisphere (North or South) and the Time Zone,
which gives an idea of the longitude.

See <URL:http://www.merlyn.demon.co.uk/js-date2.htm#SL>.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Apr 24 '07 #8
Randy Webb wrote on 24 apr 2007 in comp.lang.javascript:
Now Easter Time Zone would be cool even if my OS does indeed say
Eastern. Sheesh I should proof read sometimes.
Just this local time afternoon I parked my car with GSM-payed-parking in
Rotterdam zone 60, and 10 seconds later, after realizing I had not pressed
the 8 hard enough and after sending an end of parking, I parked in Enschede
zone 8060, some 200 km to the east of Rotterdam.

Somuch for my dual localisation now firmly documented in a police
searchable database, searchable by each traffic cop/warden's pda.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 24 '07 #9
Lee
Randy Webb said:
>IP Address? Nope. Mine will tell you that I am in New York City, New
York in the USA and I could be anywhere from NYC to Bangkok Thailand and
it will tell you the same thing.
For the OP's purposes, the location of the user's proxy seems to
be a reasonable approximation. Most of the relatively few users
with distant proxies should be able to understand what's going on.

Just provide a way to set a home location in a cookie, so it
doesn't become a nuisance.
--

Apr 25 '07 #10
Lee said the following on 4/24/2007 8:02 PM:
Randy Webb said:
>IP Address? Nope. Mine will tell you that I am in New York City, New
York in the USA and I could be anywhere from NYC to Bangkok Thailand and
it will tell you the same thing.

For the OP's purposes, the location of the user's proxy seems to
be a reasonable approximation. Most of the relatively few users
with distant proxies should be able to understand what's going on.
With 20+ million users (last I checked), are you sure that AOL users
will be able to "understand what's going on"?
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 25 '07 #11
On Apr 24, 3:13 am, Simon Brooke <s...@jasmine.org.ukwrote:
But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?
To determine the local in JavaScript use:
navigator.language for netscape flavored browsers
navigator.browserLanguage for IE

If you want to find out where (approximately) the user is, you're
probably better off using an IP->GeoLocation library/service like
Maxmind or HostIP.

You could also inspect the HTTP "Accept-Language" header in a server
side script.

-Joey

Apr 25 '07 #12
Lee
Randy Webb said:
>
Lee said the following on 4/24/2007 8:02 PM:
>Randy Webb said:
>>IP Address? Nope. Mine will tell you that I am in New York City, New
York in the USA and I could be anywhere from NYC to Bangkok Thailand and
it will tell you the same thing.

For the OP's purposes, the location of the user's proxy seems to
be a reasonable approximation. Most of the relatively few users
with distant proxies should be able to understand what's going on.

With 20+ million users (last I checked), are you sure that AOL users
will be able to "understand what's going on"?
I'm sure that AOL users are used to be confused about what's going on.
--

Apr 25 '07 #13
in message <11**********************@r3g2000prh.googlegroups. com>,
jh******@gmail.com ('jh******@gmail.com') wrote:
On Apr 24, 3:13 am, Simon Brooke <s...@jasmine.org.ukwrote:
>But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?

To determine the local in JavaScript use:
navigator.language for netscape flavored browsers
navigator.browserLanguage for IE
H'mmm... nasty. No single portable way? Still, better than nothing...
thanks.
If you want to find out where (approximately) the user is, you're
probably better off using an IP->GeoLocation library/service like
Maxmind or HostIP.

You could also inspect the HTTP "Accept-Language" header in a server
side script.
Yes, I know I can. I can do lots of things server side. What I want to know
is how to do it client side.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; I'd rather live in sybar-space

Apr 25 '07 #14
in message <4N********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
Simon Brooke said the following on 4/24/2007 1:55 PM:
>in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
>>Simon Brooke said the following on 4/24/2007 6:13 AM:
I'm working on a system which uses Google maps. I want the user to see
a map of more or less where (s)he is in the world when (s)he first
comes to the system. So the obvious thing seemed to be to have a
look-up table of latitude and longitude against locale, and then use
the locale of the browser...
No, the obvious solution is to ask them where they are in the world and
then show it on the Map.

I don't want to ask them; that's interfering with the immediacy of their
experience of the system. It's worse than a click-through page.

Then you have no way of doing what you are wanting to do.
>>>But going through the documentation I can't find any reliable way of
getting the locale in JavaScript.
There isn't one as the PC itself doesn't even know where it is in the
world.

The PC knows its locale, however, and the locale is a good enough
approximation for my purposes.

It does? Please, oh please, tell me what PC/OS setting tells you where I
am located - geographically. I don't believe you.
I didn't say your geographical location, I said your locale. In Windows,
you'll find it in Control Panel/Regional and Language Options.
>>>Am I missing something, or is this impossible?
Only way is to ask the user. Otherwise, yes, it is impossible.

If it's impossible, why is it impossible?
It is impossible because it is not possible.

But if I run a Java applet on the same PC, suddenly it's possible.

No it isn't.
So what part of java.util.Locale.getDefault() do you not understand?
>So why is it possible for an applet but not for Javascript?

Because it isn't possible for an Applet to give you my Geographical
location.
I didn't say your geographical location, I said your locale.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

Error 1109: There is no message for this error

Apr 25 '07 #15
in message <Xn********************@194.109.133.242>, Evertjan.
('e***************@interxnl.net') wrote:
Simon Brooke wrote on 24 apr 2007 in comp.lang.javascript:
>in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:
>>Simon Brooke said the following on 4/24/2007 6:13 AM:
>>>If it's impossible, why is it impossible?

It is impossible because it is not possible.

But if I run a Java applet on the same PC, suddenly it's possible. So
why is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to
get the locale. But it seems a baroque way to do it.

It is spelled out for you: You think you know where Randy is located, but
HikksNotAtHome, as he is expecting a nymphomaniac blonde on an island.
.... Sorry, I'm mixing threads.

It is not possible because browser security won't let you access the most
private parts of the client's operating system.
So what part of java.util.Locale.getDefault() do you not understand? Why is
it a security issue in JavaScript (which can, after all, get the
client-side time) but not in Java?

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
;; Skill without imagination is craftsmanship and gives us
;; many useful objects such as wickerwork picnic baskets.
;; Imagination without skill gives us modern art.
;; Tom Stoppard, Artist Descending A Staircase
Apr 25 '07 #16
in message <oP**************@invalid.uk.co.demon.merlyn.inval id>, Dr J R
Stockton ('j**@merlyn.demon.co.uk') wrote:
In comp.lang.javascript message <lr************@gododdin.internal.jasmin
e.org.uk>, Tue, 24 Apr 2007 11:13:41, Simon Brooke
<si***@jasmine.org.ukposted:
>>I'm working on a system which uses Google maps. I want the user to see a
map of more or less where (s)he is in the world when (s)he first comes to
the system. So the obvious thing seemed to be to have a look-up table of
latitude and longitude against locale, and then use the locale of the
browser...

But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?

Standards do not call for it, and it should be easy enough to ask if not
known, store it in a cookie, and have a means of changing the setting.

Until all PCs include Galileo or similar, it's not safe to assume that
the locale setting of the PC matches its geographical whereabouts.
True, and fair enough. But on the whole most users will have their locale
set to somewhere they're familiar with and interested in, even if they
aren't there at the time. Currently everyone who comes to my system sees
an initial map of the UK, and it would really be nicer if French people
saw a map of France, and Australians saw a map of Australia.

Yes, granted an Australian carrying his laptop abroad would almost
certainly still get a map of Australia, but that wouldn't (I hope) be too
surprising, and he can always scroll to where he actually is.
In places which have Summer Time, and when the PC is localised for such
a place, one can tell the Hemisphere (North or South) and the Time Zone,
which gives an idea of the longitude.

See <URL:http://www.merlyn.demon.co.uk/js-date2.htm#SL>.
Yes, timezone is possible... but I'd like to get closer if I can.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

...but have you *seen* the size of the world wide spider?

Apr 25 '07 #17
Simon Brooke wrote on 25 apr 2007 in comp.lang.javascript:
>It is not possible because browser security won't let you access the
most private parts of the client's operating system.

So what part of java.util.Locale.getDefault() do you not understand?
Did I say that? No.
Why is it a security issue in JavaScript (which can, after all, get
the client-side time)
It is if javascript is part of a browser.
but not in Java?
I am not interested in Java, and this NG is about Javascript.
For this part ow your Q look for a Java NG.

Oh wait, perhaps you think that Javascript is the script version of Java?

Do you?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 25 '07 #18
in message <Xn********************@194.109.133.242>, Evertjan.
('e***************@interxnl.net') wrote:
Simon Brooke wrote on 25 apr 2007 in comp.lang.javascript:
>>It is not possible because browser security won't let you access the
most private parts of the client's operating system.

So what part of java.util.Locale.getDefault() do you not understand?

Did I say that? No.
>Why is it a security issue in JavaScript (which can, after all, get
the client-side time)

It is if javascript is part of a browser.
But JavaScript, in the browser, has exactly the same security issues that
Java, in the browser, has. So why can one do it and the other not? It
isn't a technical issue, since it can be done. It's clearly an
architectural issue, but what I'm trying to understand is what the basis
for the decisions was.
>but not in Java?

I am not interested in Java, and this NG is about Javascript.
For this part ow your Q look for a Java NG.

Oh wait, perhaps you think that Javascript is the script version of Java?
I've been teaching Java since before the stupid marketing decision to
rename LiveScript to JavaScript happened.

And yes, I'd used LiveScript before it was called JavaScript.

--
si***@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; my other religion is Emacs
Apr 25 '07 #19
Simon Brooke wrote on 25 apr 2007 in comp.lang.javascript:
in message <Xn********************@194.109.133.242>, Evertjan.
>Simon Brooke wrote on 25 apr 2007 in comp.lang.javascript:
>>>It is not possible because browser security won't let you access
the most private parts of the client's operating system.

So what part of java.util.Locale.getDefault() do you not understand?

Did I say that? No.
>>Why is it a security issue in JavaScript (which can, after all, get
the client-side time)

It is if javascript is part of a browser.

But JavaScript, in the browser, has exactly the same security issues
that Java, in the browser, has.
Why?
So why can one do it and the other not?
It isn't a technical issue, since it can be done.
Concusion based on the first wrong premise.
If it can be done, it still could be an technical issue.

But I told you ist was a security isue on the part of the browser with
Javascript.

Why it seems to be not with Java, you will have to ask in a Java NG.
It's clearly an architectural issue,
Why clearly?
What is "architectural" in this context?
Do you see security as architectural?
but what I'm trying to understand is what the
basis for the decisions was.
Ask in a Java NG, the Javascript security issue was pointed to by me.
>>but not in Java?

I am not interested in Java, and this NG is about Javascript.
For this part ow your Q look for a Java NG.

Oh wait, perhaps you think that Javascript is the script version of
Java?

I've been teaching Java since before the stupid marketing decision to
rename LiveScript to JavaScript happened.
So what? You still could have the wrong idea of the combination.
And yes,
"Yes" on the question that you really think what I surmized?
I'd used LiveScript before it was called JavaScript.
So what? I have used Fortran and Assembler.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 25 '07 #20
Lee
Evertjan. said:
>But I told you ist was a security isue on the part of the browser with
Javascript.
I think there's some miscommunication here.

You've asserted that there is a security issue with Javascript
making the Locale available. It's been pointed out that the
information can already be obtained in other ways, which quite
legitimately calls your assertion into question.

Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?
--

Apr 25 '07 #21
Lee wrote on 25 apr 2007 in comp.lang.javascript:
Evertjan. said:
>>But I told you ist was a security isue on the part of the browser with
Javascript.

I think there's some miscommunication here.

You've asserted that there is a security issue with Javascript
making the Locale available.
No, I have pointed out or wanted to point out there is a security REASON.

All mentioning of an issue by me I retract, as the word "issue" seems a
source of miscommunication.
It's been pointed out that the
information can already be obtained in other ways,
Not to my satisfaction, since I'm not even interested if there are other
ways to do something outside javascript.

These things are off topic and inconsequential.

Why the "already"?
which quite legitimately calls your assertion into question.
Why?

"It" does not call anything into question, only you do.
You are free to call anything into question, this is usenet.

Do you have spontaneous urges to be "legitimate"?
Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?
I never support assertions made by someone else.
Is wanting support another spontaneous urge?

As I said:
I have pointed out or wanted to point out there is a security REASON.

I add:
I did not point out that it was or should be a valid reason.
I think it is a reasonable reason.

That reason does not depend on others implementing
the same in another language.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 25 '07 #22
Lee
Evertjan. said:
>
Lee wrote on 25 apr 2007 in comp.lang.javascript:
>Evertjan. said:
>>>But I told you ist was a security isue on the part of the browser with
Javascript.

I think there's some miscommunication here.

You've asserted that there is a security issue with Javascript
making the Locale available.

No, I have pointed out or wanted to point out there is a security REASON.
In your understanding of English, how do you differentiate between
there being a "security issue" and a "security reason"?

What is the security reason?

> It's been pointed out that the
information can already be obtained in other ways,

Not to my satisfaction, since I'm not even interested if there are other
ways to do something outside javascript.

These things are off topic and inconsequential.

Why the "already"?
>which quite legitimately calls your assertion into question.

Why?

"It" does not call anything into question, only you do.
You are free to call anything into question, this is usenet.

Do you have spontaneous urges to be "legitimate"?
If the information can be obtained via the browser, by any
means at all, then any restriction set by Javascript is
pointless, isn't it?

>Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?

I never support assertions made by someone else.
Is wanting support another spontaneous urge?
Why are you being such an asshole?
--

Apr 25 '07 #23
Simon Brooke wrote:
in message <Xn********************@194.109.133.242>, Evertjan.
('e***************@interxnl.net') wrote:
>Simon Brooke wrote on 24 apr 2007 in comp.lang.javascript:
>>in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:

Simon Brooke said the following on 4/24/2007 6:13 AM:
If it's impossible, why is it impossible?
It is impossible because it is not possible.
But if I run a Java applet on the same PC, suddenly it's possible. So
why is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to
get the locale. But it seems a baroque way to do it.
It is spelled out for you: You think you know where Randy is located, but
HikksNotAtHome, as he is expecting a nymphomaniac blonde on an island.
.... Sorry, I'm mixing threads.

It is not possible because browser security won't let you access the most
private parts of the client's operating system.

So what part of java.util.Locale.getDefault() do you not understand? Why is
it a security issue in JavaScript (which can, after all, get the
client-side time) but not in Java?
Totally off topic, but "return the default locale for this JVM" suffers
from exactly what Randy mentioned above. His default location may not
be his geographical location.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Apr 26 '07 #24
-Lost wrote:
Simon Brooke wrote:
>in message <Xn********************@194.109.133.242>, Evertjan.
('e***************@interxnl.net') wrote:
>>Simon Brooke wrote on 24 apr 2007 in comp.lang.javascript:

in message <AK********************@giganews.com>, Randy Webb
('H*************@aol.com') wrote:

Simon Brooke said the following on 4/24/2007 6:13 AM:
>If it's impossible, why is it impossible?
It is impossible because it is not possible.
But if I run a Java applet on the same PC, suddenly it's possible. So
why is it possible for an applet but not for Javascript? What is the
architectural choice being made here, and what is it being made for?

Actually that may be the solution - run a single-pixel applet just to
get the locale. But it seems a baroque way to do it.
It is spelled out for you: You think you know where Randy is located,
but
HikksNotAtHome, as he is expecting a nymphomaniac blonde on an island.
.... Sorry, I'm mixing threads.

It is not possible because browser security won't let you access the
most
private parts of the client's operating system.

So what part of java.util.Locale.getDefault() do you not understand?
Why is
it a security issue in JavaScript (which can, after all, get the
client-side time) but not in Java?

Totally off topic, but "return the default locale for this JVM" suffers
from exactly what Randy mentioned above. His default location may not
be his geographical location.
Hrmm... after further reading it seems that I am confusing locale with
location.

The second definition at Dictionary dot com threw me.

Nevermind my post.

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Apr 26 '07 #25
But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?
It is possible to determine the locale through JavaScript.
For netscape flavored browsers use: navigator.language
For Internet Explorer use: navigator.browserLanguage

That being said, if your goal is to determine the geographical
location of the user, you're better off using an IP->Location library/
service like that offered by Maxmind or Hostip.info

-Joey

Apr 26 '07 #26
On Apr 25, 8:11 pm, Simon Brooke <s...@jasmine.org.ukwrote:
in message <1177473080.796542.163...@r3g2000prh.googlegroups. com>,

jhurs...@gmail.com ('jhurs...@gmail.com') wrote:
On Apr 24, 3:13 am, Simon Brooke <s...@jasmine.org.ukwrote:
But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?
What do you mean by "locale"? Do you mean timezone? Country?
Approximate geographic location to within say 1,000 km?

Why is it impossible? Because there is no standard that says it must
be available and browser developers have, in general, considered it
unsuitable to include as an extension. As for why they consider it
unsuitable, you'd better ask them.

To determine the local in JavaScript use:
navigator.language for netscape flavored browsers
navigator.browserLanguage for IE

H'mmm... nasty. No single portable way? Still, better than nothing...
thanks.
Yes, nasty advice - using the language setting is worse than nothing.
Mine says "en-GB", but if you think that means I am in Great Britain,
you're very wrong. My timezone is GMT+10.

If you want to find out where (approximately) the user is, you're
probably better off using an IP->GeoLocation library/service like
Maxmind or HostIP.
You could also inspect the HTTP "Accept-Language" header in a server
side script.
The language setting for a browser has no bearing on geographical
location.

Yes, I know I can. I can do lots of things server side. What I want to know
is how to do it client side.
To what level of accuracy? You can determine the timezone, which gets
you within maybe 10 degrees of longitude *if* the user has set it
correctly for the location they are in, but that's it. The language
might give you a clue in regard to latitude, but I doubt it is
reliable at all.

How do you reconcile GMT+8 and en-US?
--
Rob

Apr 26 '07 #27
Lee wrote on 26 apr 2007 in comp.lang.javascript:
>>No, I have pointed out or wanted to point out there is a security
REASON.

In your understanding of English, how do you differentiate between
there being a "security issue" and a "security reason"?
You brought up "miscommunication"!

"Issue" can mean many things:
"I have a behavoural issue" could mean "I am a psychopath".
[has nothing to do with the reason, I am sure]
What is the security reason?
The reason for the security.

.... that my locale setting is non of your business,
and not intended to be shown to the web.
>
>> It's been pointed out that the
information can already be obtained in other ways,

Not to my satisfaction, since I'm not even interested if there are
other ways to do something outside javascript.

These things are off topic and inconsequential.

Why the "already"?
Why do you not anwer?
>>
>>which quite legitimately calls your assertion into question.

Why?
Why do you not anwer?
>>"It" does not call anything into question, only you do.
You are free to call anything into question, this is usenet.

Do you have spontaneous urges to be "legitimate"?

If the information can be obtained via the browser, by any
means at all, then any restriction set by Javascript is
pointless, isn't it?
It ia as if [the following is just an example] Firefox would he no reason
to implement security, because the security of MSIE is not up to that
standard.

Reasons do not even have to be valid to be used,
not even by javascript engine builders,
as long as they think it is valid and useful.

However if it is as you say with the ability of Java, that you can do
with java what you can nnot do with javascript in a browser, I could, by
switching off java support, be safe from you finding my "locale
settings".

That seems a good enough reason to me for the javascript implementation.
>>Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?

I never support assertions made by someone else.
Is wanting support another spontaneous urge?

Why are you being such an asshole?
So it is that, having no arguments, you resort to foul language?

So much for spontaneous urges! ;-) ;-)

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 26 '07 #28
Lee
Evertjan. said:
>
Lee wrote on 26 apr 2007 in comp.lang.javascript:
>>>No, I have pointed out or wanted to point out there is a security
REASON.

In your understanding of English, how do you differentiate between
there being a "security issue" and a "security reason"?

You brought up "miscommunication"!
Why do you not answer?

>"Issue" can mean many things:
"I have a behavoural issue" could mean "I am a psychopath".
[has nothing to do with the reason, I am sure]
>What is the security reason?

The reason for the security.
Why do you not answer?

>... that my locale setting is non of your business,
and not intended to be shown to the web.
Why not? What is dangerous about knowing your locale?

>>> It's been pointed out that the
information can already be obtained in other ways,

Not to my satisfaction, since I'm not even interested if there are
other ways to do something outside javascript.

These things are off topic and inconsequential.

Why the "already"?

Why do you not anwer?
I answered below.

>>>which quite legitimately calls your assertion into question.

Why?

Why do you not anwer?
I answered below.

>>>"It" does not call anything into question, only you do.
You are free to call anything into question, this is usenet.

Do you have spontaneous urges to be "legitimate"?

If the information can be obtained via the browser, by any
means at all, then any restriction set by Javascript is
pointless, isn't it?

It ia as if [the following is just an example] Firefox would he no reason
to implement security, because the security of MSIE is not up to that
standard.
No, you're not understanding. The posted said that it is available
in any browser via a Java applet. If it is available in any browser,
then it is pointless to to block it via Javascript, isn't it?

>Reasons do not even have to be valid to be used,
not even by javascript engine builders,
as long as they think it is valid and useful.
So, you're suggesting that security is the *excuse*, and that there
is actually no valid reason?
>However if it is as you say with the ability of Java, that you can do
with java what you can nnot do with javascript in a browser, I could, by
switching off java support, be safe from you finding my "locale
settings".

That seems a good enough reason to me for the javascript implementation.
Think that through. Can you imagine the designers sitting around
deciding whether to make some information visible, and deciding
that it's ok, because the users can simply disable support for
Java if they don't like it?

>>>Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?

I never support assertions made by someone else.
Is wanting support another spontaneous urge?

Why are you being such an asshole?

So it is that, having no arguments, you resort to foul language?
Which of my arguments did you not understand?

I raised some legitimate questions about your position, and
you resorted to questioning my "urges". If you don't want me
to point out that your logic is flawed, use better logic.
If you don't want me to point out that you're acting like an
asshole, don't act like one.
--

Apr 26 '07 #29
Lee wrote on 26 apr 2007 in comp.lang.javascript:
>>It ia as if [the following is just an example] Firefox would he no
reason to implement security, because the security of MSIE is not up
to that standard.

No, you're not understanding. The posted said that it is available
in any browser via a Java applet. If it is available in any browser,
then it is pointless to to block it via Javascript, isn't it?

>>Reasons do not even have to be valid to be used,
not even by javascript engine builders,
as long as they think it is valid and useful.

So, you're suggesting that security is the *excuse*, and that there
is actually no valid reason?
I did not. I said that the rweason someone did something does not have to
be valid, if you only ask for the reason.

I think ansd showed the reason is very valid, but that is another story

>>However if it is as you say with the ability of Java, that you can do
with java what you can nnot do with javascript in a browser, I could,
by switching off java support, be safe from you finding my "locale
settings".

That seems a good enough reason to me for the javascript
implementation.

Think that through. Can you imagine the designers sitting around
deciding whether to make some information visible, and deciding
that it's ok, because the users can simply disable support for
Java if they don't like it?
I do not think you should not close the locks on your home, because the
hedge on the window is faulty.
>>>>Can you support the assertion that there are security reasons
for not making the Locale setting available via Javascript?

I never support assertions made by someone else.
Is wanting support another spontaneous urge?

Why are you being such an asshole?

So it is that, having no arguments, you resort to foul language?

Which of my arguments did you not understand?

I raised some legitimate questions about your position,
So you maintain "asshole" is legitimate, I end my part in this thread.
and
you resorted to questioning my "urges". If you don't want me
to point out that your logic is flawed, use better logic.
If you don't want me to point out that you're acting like an
asshole, don't act like one.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 26 '07 #30
Lee
Evertjan. said:
>
Lee wrote on 26 apr 2007 in comp.lang.javascript:
>>>It ia as if [the following is just an example] Firefox would he no
reason to implement security, because the security of MSIE is not up
to that standard.

No, you're not understanding. The posted said that it is available
in any browser via a Java applet. If it is available in any browser,
then it is pointless to to block it via Javascript, isn't it?

>>>Reasons do not even have to be valid to be used,
not even by javascript engine builders,
as long as they think it is valid and useful.

So, you're suggesting that security is the *excuse*, and that there
is actually no valid reason?

I did not. I said that the rweason someone did something does not have to
be valid, if you only ask for the reason.

I think ansd showed the reason is very valid, but that is another story
I guess you just don't understand English as well as I thought.
--

Apr 26 '07 #31
In comp.lang.javascript message <sYOdnXFcHZ1UabLbnZ2dnUVZ_uSgnZ2d@comcas
t.com>, Wed, 25 Apr 2007 20:40:19, -Lost <ma****************@techie.com>
posted:
>
Totally off topic, but "return the default locale for this JVM" suffers
from exactly what Randy mentioned above. His default location may not
be his geographical location.

There are two quite distinct concepts involved, each in part known to a
Windows or similar O.S.

There is geographical location. The best that can be done, AFAIK, is to
determine the Winter Time offset from GMT of the assigned locality and
maybe the sign of the latitude. Those settings will usually be correct
for the machine's base location.

There are the cultural settings - date format, currency symbol, decimal
separator. At least some of those are known to, or may be deducible by,
VBScript; and can then be passed on in a web page to javascript, for
those using VBS-compatible browsers.

<script type=text/vbscript>
SSS = CStr(Now)
</script>
<script type=text/javascript>
document.writeln(SSS, "<br>")
document.writeln(new Date().toLocaleString())
</script>

But modification may be needed to make that fail benignly in systems
where it does not work.

For some purposes, the current geographical location is the only
relevant location; for others, the base location is far more significant
- one should not presume that Randy wants the cricket scores just
because he's visiting Barbados, or that the Duke's PA's machine should
necessarily be offered the baseball scores when he's at GSFC.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6.
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Apr 26 '07 #32
Dr J R Stockton wrote on 26 apr 2007 in comp.lang.javascript:
one should not presume that Randy wants the cricket scores just
because he's visiting Barbados
Still, if you have corroborating evidence like Randy's selfprofessed
preference for blondes, noticeably in a minority on that island, you could.

Distilling web guest's localisations by some clever browsing choices
offered on a page, like local weather and traffic info choices, could be
useful to get a statistical estimate of your visitor's habitad, especially
when correlating it with the visitor's IP.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Apr 27 '07 #33
You can get the Geolocation library from http://www.ip2location.com

Jun 3 '07 #34

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.