By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,936 Members | 1,396 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,936 IT Pros & Developers. It's quick & easy.

knowing where the user comes from

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
microgolf <mi*******@gmail.comwrites:
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/
Jun 27 '08 #2

P: n/a
In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
<mi*******@gmail.composted:
>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)
Jun 27 '08 #3

P: n/a
On Jun 6, 5:44*pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
<microg...@gmail.composted:
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)
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.
Jun 27 '08 #4

P: n/a
VK
On Jun 7, 3:07 am, Tom Cole <tco...@gmail.comwrote:
On Jun 6, 5:44 pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
In comp.lang.javascript message <d70ff805-94df-4a01-8aeb-5cd0d884acbe@m7
3g2000hsh.googlegroups.com>, Fri, 6 Jun 2008 11:05:21, microgolf
<microg...@gmail.composted:
>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)

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);
Jun 27 '08 #5

P: n/a
On Jun 6, 8:26*pm, Joost Diepenmaat <jo...@zeekat.nlwrote:
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.
Jun 27 '08 #6

P: n/a
microgolf wrote:
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
Jun 27 '08 #7

P: n/a
Tom Cole wrote:
On Jun 6, 5:44 pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
>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.
And then use that to help you determine.
Don't.
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.
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
Jun 27 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.