473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

knowing where the user comes from

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
7 1149
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Google Mike | last post by:
You know, while working on my moonlight corporation's LAMP project at home this weekend, I couldn't help but wonder if people writing similar projects are solving similar problems with having to...
8
by: IGC | last post by:
I have a requirement to record in a database when a file is finished downloading to the end-user. Currently when a user clicks a download icon for a file it directs to an ASP page that records the...
2
by: Niklas Ringdahl | last post by:
Hello. I am using databindings to bind my dataset to comboboxes, textboxes and labels. Some of my UI depends on knowing when the user changes the values, but I have some problems knowing when my...
3
by: Amir Eshterayeh | last post by:
Dear Friends Would you please give me your professional idea about this asp.net problem. I need different virtual directory for different customer with their names like these:...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
9
by: TCORDON | last post by:
I have a user control that contains 2 image buttons, when you click one of them, both must change the image source, the thing is that the first time you click any one of them the page appears to do...
1
by: Ramesh | last post by:
Hello all, I have a form in which I'm trying to load a user control depending on some user choice, and my control's events are not firing properly. Here's a completely stripped down repro of the...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
1
by: commodityintelligence | last post by:
Greetings, I am merging a series of different tables into one query to export decision-making information. I have some architecture issues I need to ask for help on. I have no programming...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...

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.