HighDots Forums  

knowing where the user comes from

Javascript JavaScript language (comp.lang.javascript)


Discuss knowing where the user comes from in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
microgolf
 
Posts: n/a

Default knowing where the user comes from - 06-06-2008 , 02:05 PM






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

Reply With Quote
  #2  
Old   
Joost Diepenmaat
 
Posts: n/a

Default Re: knowing where the user comes from - 06-06-2008 , 02:26 PM






microgolf <microgolf (AT) gmail (DOT) com> writes:

Quote:
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?
There are ways to determine the user's location (with more or less
precision) based on his IP address. On the other hand, it would be
better to just use the user's language preference instead of his
location. Conveniently, the language preference is send to the server
at each request. On the third hand, most users never change their
language preference (though local vendors may have set it for them).

See, for example:
http://www.w3.org/International/ques...t-lang-locales

Which isn't really about language, but does touch on most of the
relevant issues.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


Reply With Quote
  #3  
Old   
Dr J R Stockton
 
Posts: n/a

Default Re: knowing where the user comes from - 06-06-2008 , 05:44 PM



In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
<microgolf (AT) gmail (DOT) com> posted:

Quote:
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?
The place where the user is, the place where the user lives, and the
place where the user comes from, and the places where the user's
preferred language originated or is common, are not necessarily the
same. And the computer is not necessarily set to the local language.

Consider a hypothetical Ambassador to Poland who was born in Korea and
is visiting the residence of the French Ambassador to Bulgaria, and who
wants to read about a baseball game.

To find what language the user wants, ask the user, as Wikipedia does.

--
(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)


Reply With Quote
  #4  
Old   
Tom Cole
 
Posts: n/a

Default Re: knowing where the user comes from - 06-06-2008 , 07:07 PM



On Jun 6, 5:44*pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:
Quote:
In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
microg... (AT) gmail (DOT) com> posted:

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?

The place where the user is, the place where the user lives, and the
place where the user comes from, and the places where the user's
preferred language originated or is common, are not necessarily the
same. *And the computer is not necessarily set to the local language.

Consider a hypothetical Ambassador to Poland who was born in Korea and
is visiting the residence of the French Ambassador to Bulgaria, and who
wants to read about a baseball game.

To find what language the user wants, ask the user, as Wikipedia does.

--
*(c) John Stockton, nr London, UK. ?... (AT) merlyn (DOT) demon.co.uk *Turnpike v6.05 *MIME.
*Web *<URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
*Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
*Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
You may also try using something like:

var lang = navigator['language'] || navigator['userLanguage'];

And then use that to help you determine. For example mine returns en-
us (or en-Us or en-US, depending on the browser).

Of course the best way is to ask.


Reply With Quote
  #5  
Old   
VK
 
Posts: n/a

Default Re: knowing where the user comes from - 06-07-2008 , 02:55 AM



On Jun 7, 3:07 am, Tom Cole <tco... (AT) gmail (DOT) com> wrote:
Quote:
On Jun 6, 5:44 pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:



In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
microg... (AT) gmail (DOT) com> posted:

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?

The place where the user is, the place where the user lives, and the
place where the user comes from, and the places where the user's
preferred language originated or is common, are not necessarily the
same. And the computer is not necessarily set to the local language.

Consider a hypothetical Ambassador to Poland who was born in Korea and
is visiting the residence of the French Ambassador to Bulgaria, and who
wants to read about a baseball game.

To find what language the user wants, ask the user, as Wikipedia does.

--
(c) John Stockton, nr London, UK. ?... (AT) merlyn (DOT) demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)

You may also try using something like:

var lang = navigator['language'] || navigator['userLanguage'];

And then use that to help you determine. For example mine returns en-
us (or en-Us or en-US, depending on the browser).

Of course the best way is to ask.
The best way is to make an educated guess first - but to leave an
option to change if the guess is wrong. As it was pointed out, there
may be tricky occasional situations, say an American contractor in
Germany using office PS with German Windows XP but en-US Firefox or
IE. Or even German OS, German browser but preferred content language
manually set to en-US. Unfortunately navigator.userLanguage (IE) and
especially navigator.language (some others) are currently very lousy
implemented in this aspect. They are still usable for an educated
guess but an option for manual language switch should be provided.

var lang = (navigator.userLanguage || navigator.language ||
defaultLanguage);


Reply With Quote
  #6  
Old   
Jorge
 
Posts: n/a

Default Re: knowing where the user comes from - 06-07-2008 , 07:24 AM



On Jun 6, 8:26*pm, Joost Diepenmaat <jo... (AT) zeekat (DOT) nl> wrote:

Quote:
There are ways to determine the user's location (with more or less
precision) based on his IP address.
But then, keep in mind that she might be coming trough a proxy.

--Jorge.


Reply With Quote
  #7  
Old   
Dan Rumney
 
Posts: n/a

Default Re: knowing where the user comes from - 06-07-2008 , 01:34 PM



microgolf wrote:
Quote:
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?

Other posters have pointed out some of the vagaries of language detection.

It's probably worth pointing out that there is an Accept-Language header
that exists in an HTTP Request, so this is something that your webserver
could handle.

For example:
http://httpd.apache.org/docs/2.0/con...gotiation.html

Just an option for you to consider


Reply With Quote
  #8  
Old   
Thomas 'PointedEars' Lahn
 
Posts: n/a

Default Re: knowing where the user comes from - 06-07-2008 , 01:45 PM



Tom Cole wrote:
Quote:
On Jun 6, 5:44 pm, Dr J R Stockton <j... (AT) merlyn (DOT) demon.co.uk> wrote:
microgolf posted:
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?
The place where the user is, the place where the user lives, and the
place where the user comes from, and the places where the user's
preferred language originated or is common, are not necessarily the
same. And the computer is not necessarily set to the local language.

Consider a hypothetical Ambassador to Poland who was born in Korea and
is visiting the residence of the French Ambassador to Bulgaria, and who
wants to read about a baseball game.

To find what language the user wants, ask the user, as Wikipedia does.
[...]
You may also try using something like:

var lang = navigator['language'] || navigator['userLanguage'];
You can use dot notation instead, the property names are identifiers here.

Quote:
And then use that to help you determine.
Don't.

Quote:
For example mine returns en-us (or en-Us or en-US, depending on the browser).
My Firefox would yield "en-US" even though neither am I a speaker of English
as first language, nor is the country I live in and I am are currently
located in called The United States of America.

Quote:
Of course the best way is to ask.
Most definitely. However, the Accept-Language header provides a much better
hint than any `navigator' properties.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.