Hi all,
If I want to detect a user's language, so that I can
change some text to suit them, how do I do that in
Javascript?
Or aren't modern browsers supposed to be able
to cope with more than one language on a page,
separated somehow by language identifiers,
and display only the appropriate text? Maybe
I was dreaming when I read that...
Thanks. 6 1666
Rex wrote:
If I want to detect a user's language, so that I can
change some text to suit them, how do I do that in
Javascript?
Or aren't modern browsers supposed to be able
to cope with more than one language on a page,
separated somehow by language identifiers,
and display only the appropriate text? Maybe
I was dreaming when I read that...
At least in Microsoft Internet Explorer, you have 3 languages to read
out:
navigator.systemLanguage
navigator.userLanguage
navigator.browserLanguage
If you want to read out the browser's language in a FF/MSIE/NS
compatible manner, you could do something like this:
var lang = 'unknown';
if (navigator.browserLanguage)
lang = navigator.browserLanguage;
if (navigator.language)
lang = navigator.language;
document.write(lang);
Hope this helps,
--
Bart
Rex wrote:
If I want to detect a user's language, so that I can
change some text to suit them, how do I do that in
Javascript?
This is something better handled on the server: http://www.cs.tut.fi/~jkorpela/multi/index-en.htm
--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
David Dorward wrote:
Rex wrote:
If I want to detect a user's language, so that I can
change some text to suit them, how do I do that in
Javascript?
This is something better handled on the server: http://www.cs.tut.fi/~jkorpela/multi/index-en.htm
Not necessarily. You would be using the language setting that the
browser broadcasts anyhow. Of course, there is something to say for
surfers who have disabled javascript in their browser, but that is
something that actually applies to almost any post in this group.
--
Bart
Bart Van der Donck wrote:
David Dorward wrote:
>Rex wrote:
>>If I want to detect a user's language, so that I can change some text to suit them, how do I do that in Javascript?
This is something better handled on the server: http://www.cs.tut.fi/~jkorpela/multi/index-en.htm
Not necessarily. You would be using the language setting that the
browser broadcasts anyhow. Of course, there is something to say for
surfers who have disabled javascript in their browser,
And the user's of browsers that do not expose any language information
(and there is no current public standard that says they must).
but that is something that actually applies to almost any post
in this group.
Yes, it is a fundamental issue in Internet browser scripting, which
makes doing what can be done on the server on the sever often the best
advice available in response to javascript questions.
Richard.
Richard Cornford wrote:
Bart Van der Donck wrote:
David Dorward wrote:
Rex wrote: If I want to detect a user's language, so that I can change some text to suit them, how do I do that in Javascript?
This is something better handled on the server: http://www.cs.tut.fi/~jkorpela/multi/index-en.htm
Not necessarily. You would be using the language setting that the
browser broadcasts anyhow. Of course, there is something to say for
surfers who have disabled javascript in their browser,
And the user's of browsers that do not expose any language information
(and there is no current public standard that says they must).
[...]
I've also seen firewalls that block browser environmental variables, so
they can't reach the web server anyhow.
--
Bart
Bart Van der Donck wrote:
Richard Cornford wrote:
<snip>
>>Not necessarily. You would be using the language setting that the browser broadcasts anyhow. Of course, there is something to say for surfers who have disabled javascript in their browser,
And the user's of browsers that do not expose any language information (and there is no current public standard that says they must). [...]
I've also seen firewalls that block browser environmental variables, so
they can't reach the web server anyhow.
Blocking Accept-Language wouldn't be the smartest thing for a firewall
to do, as it is to the user's advantage to be served the language of
their preference(s).
Richard. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Hal |
last post by:
Can someone please tell me what is wrong with this script?
<script language="JavaScript">
<!--
function HF_CloseAllChildren() {
if (g_win1) != undefined {
if ((g_win1) && !(g_win1.closed))...
|
by: Ryan Stewart |
last post by:
I'm working on a project to collect web application usage statistics. What
are the recommended ways of detecting whether a browser is JavaScript
enabled and/or capable? Obviously I can write a...
|
by: guischarf |
last post by:
I have the following code on files "a.php" and "b.php"
-----------------------------
FILE a.php
-----------------------------
<form action="a.php" method="post">
<input type="hidden"...
|
by: Simon Harvey |
last post by:
Hi everyone,
I'm having a frustrating problem and I don't know how to fix it without
totally redoing a very complicated couple of pages on my site. I really hope
some kind soul can help me :-)
...
|
by: jens Jensen |
last post by:
Hello,
I have two version of a site. I need to redirect users based on the language
i think the speak/understand.
Any idea how to best do this?
Many thanks in advanc
JJ
|
by: VK |
last post by:
I wandering about the common proctice of some UA's producers to spoof
the UA string to pretend to be another browser (most often IE).
Shouldn't it be considered as a trademark violation of the...
|
by: wwwords |
last post by:
Is there a general method for detecting that a user has changed the
record currently visible on a form, whether this is by hitting PgUp or
PgDn or clicking on a navigation button, even if no change...
|
by: mouton |
last post by:
Hello,
I am a beginner. My website has 2 pages: one in English and one in
French. I would like non English people to be directed to the English
page. There I would like to display a...
|
by: Sems |
last post by:
Hi
I'm using the Session_End event in the global.asax to detect if a
users sessions has ended. Is there any way to tell if the session end
is due to it being expired and not abandoned?
I'm...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |