How to detect client language?

Discussion in 'Javascript' started by Chris Fynn, Oct 28, 2003.

  1. Chris Fynn

    Chris Fynn Guest

    Is there an easy way to detect the local language settings of a client
    browser or system?

    I want to for example determine if the users browser or system is set to
    English, French, or Italian and display a message in the appropriate
    language.


    --
    Christopher J. Fynn
     
    Chris Fynn, Oct 28, 2003
    #1
    1. Advertising

  2. Chris Fynn

    Stephen Guest

    Hi there ...
    Chris Fynn wrote:
    > Is there an easy way to detect the local language settings of a client
    > browser or system?
    >
    > I want to for example determine if the users browser or system is set to
    > English, French, or Italian and display a message in the appropriate
    > language.
    >


    Seems like there was a thread on about this topic about a month or so
    ago; maybe a little longer. Seems like the solution revolved around
    examining the HTTP_ACCEPT_LANGUAGE environment variable at the server.
    Maybe google for "check HTTP_ACCEPT_LANGUAGE" and see if that doesn't
    find it.

    Regards,
    Stephen
     
    Stephen, Oct 29, 2003
    #2
    1. Advertising

  3. Hallo

    IE has a navigator property which is
    navigator.systemLanguage
    and also
    navigator.userLanguage
    it returns intenrational codes for nationalities: exaple 'it' for Italy.
    NS6 has a
    navigator.language
    property which returns a slightly different value: for english it returns
    en-US

    if you want you can open with different browsers the following file I made:

    http://www.unitedscripters.com/hotvamps/browsers.html

    upon loading it will list all the properties for each object in a select
    menu (starts with the window object of course), upon selection it will
    unfold the selected object too (if it is an object). In the second half of
    the file you can provide yourself objects, such as "navigator" and click
    "Populate" - on both sections you'll see properties, data type, and values
    as well. You can check with all the browsers you prefer. I think that can be
    helpful to inspect a great deal of properties we webmasters are not always
    familiar with or we didn't even know they existed.
    You can also check DOM objects as they get unfolded. To reset, reload the
    page.

    I have not checked with NS4 though - ok I do it now...
    yeah it has
    navigator.language
    too and for it reports "en" for english.
    You can check by
    var
    language=(navigator["language"])?navigator["language"]:navigator["userLangua
    ge"];

    allow for a value "undefined" for browsers that don't fall in either scope.
    ciao
    Alberto Vallini
    http://www.unitedscripters.com/

    "Chris Fynn" <remove%20chris_fynn%20@%20hotmail.%20com%20.remove> ha scritto
    nel messaggio news:bnmqq2$5kh$...
    > Is there an easy way to detect the local language settings of a client
    > browser or system?
    >
    > I want to for example determine if the users browser or system is set to
    > English, French, or Italian and display a message in the appropriate
    > language.
    >
    >
    > --
    > Christopher J. Fynn
    >
    >
    >
    >
     
    Vicomte De Valmont, Oct 29, 2003
    #3
  4. Chris Fynn wrote:

    > I want to for example determine if the users browser or system is set to
    > English, French, or Italian and display a message in the appropriate
    > language.


    Your request is based on the false assumption that a French, working in
    the UK with the French language pack of the English browser and French
    keyboard layout on a system with an English-UK locale, is not interested
    in the Italian version of the site. Use server-side Content Negotiation
    along with language links (without flags!) and let your visitors decide
    what they want to see.

    > --
    > Christopher J. Fynn


    Please read the OE-FAQ and repair your b0rken signature separator.
    It is required to be `-- ' (dash-dash-space) to work but you will
    not accomplish this with OE alone (since it removes trailing spaces
    on post).


    PointedEars
     
    Thomas 'PointedEars' Lahn, Nov 23, 2003
    #4
  5. Chris Fynn

    Fabian Guest

    Chris Fynn hu kiteb:

    > Is there an easy way to detect the local language settings of a client
    > browser or system?
    >
    > I want to for example determine if the users browser or system is
    > set to English, French, or Italian and display a message in the
    > appropriate language.


    No thank you. I have to work with Japanese windows (local market means
    English windows is ludicrously expensive, and will disable some
    essential software I use), but where possible, I prefer an English
    interface. Please, DON'T autodetect this. Ask the user.

    Oh, and don't use flags when you ask the user ;)


    --
    --
    Fabian
    Visit my website often and for long periods!
    http://www.lajzar.co.uk
     
    Fabian, Nov 24, 2003
    #5
  6. How to detect client language?

    JRS: In article <>, seen in
    news:comp.lang.javascript, Thomas 'PointedEars' Lahn
    <> posted at Sun, 23 Nov 2003 22:41:45 :-

    >Please read the OE-FAQ and repair your b0rken signature separator.
    >It is required to be `-- ' (dash-dash-space) to work but you will


    The word is "broken"; use of Merkin slang is discourteous to those who
    are trying to learn good English.

    To be a SigSep, dash-dash-space must be the only thing on the line.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
     
    Dr John Stockton, Nov 24, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matthias S.

    Save way to detect Browser Language

    Matthias S., Mar 30, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    8,469
    cauzon
    Dec 28, 2007
  2. Ed
    Replies:
    24
    Views:
    1,075
    Dimitri Maziuk
    Mar 27, 2006
  3. DaveInSidney
    Replies:
    0
    Views:
    468
    DaveInSidney
    May 9, 2005
  4. pabbu
    Replies:
    8
    Views:
    773
    Marc Boyer
    Nov 7, 2005
  5. Raj
    Replies:
    3
    Views:
    282
    Grant Wagner
    Apr 21, 2004
Loading...

Share This Page