Detects the language used by the client's browser : Browser Info « Window Browser « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Dojo toolkit
7. Event
8. Event onMethod
9. Ext JS
10. Form Control
11. GUI Components
12. HTML
13. Javascript Collections
14. Javascript Objects
15. Javascript Properties
16. jQuery
17. Language Basics
18. Mochkit
19. Mootools
20. Node Operation
21. Object Oriented
22. Page Components
23. Rico
24. Scriptaculous
25. Security
26. SmartClient
27. Style Layout
28. Table
29. Utilities
30. Window Browser
31. YUI Library
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
JavaScript DHTML » Window Browser » Browser Info 
Detects the language used by the client's browser
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>

  <HEAD>
    <TITLE>JsLib 1.3 - Exemple - langue.js</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
    <META NAME="Author" CONTENT="Etienne CHEVILLARD">
    <!-- langue.js -->
    <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
/* langue.js
 * Role : detecte la langue du navigateur du client
 * Projet : JsLib
 * Auteur : Etienne CHEVILLARD (echevillard@users.sourceforge.net)
 * Version : 1.3
 * Creation : 10/04/2001
 * Mise a jour : 23/02/2005
 */

// --- Variables globales ---

// tableau des codes ISO
var langue_tabct=new Array("aa","ab","af","am","ar","as","ay","az","ba","be",
  "bg","bh","bi","bn","bo","br","ca","co","cs","cy",
  "da","de","dz","el","en","eo","es","et","eu","fa",
  "fi","fj","fo","fr","fy","ga","gd","gl","gn","gu",
  "gv","ha","he","hi","hr","hu","hy","ia","id","ie",
  "ik","is","it","iu","ja","jw","ka","kk","kl","km",
  "kn","ko","ks","ku","kw","ky","la","lb","ln","lo",
  "lt","lv","mg","mi","mk","ml","mn","mo","mr","ms",
  "mt","my","na","ne","nl","no","oc","om","or","pa",
  "pl","ps","pt","qu","rm","rn","ro","ru","rw","sa",
  "sd","se","sg","sh","si","sk","sl","sm","sn","so",
  "sq","sr","ss","st","su","sv","sw","ta","te","tg",
  "th","ti","tk","tl","tn","to","tr","ts","tt","tw",
  "ug","uk","ur","uz","vi","vo","wo","xh","yi","yo",
  "za","zh","zu");

// tableau des langues en francais
var langue_tablg=new Array("Afar","Abkhaze","Afrikaans","Amharique","Arabe",
  "Assamais","Aymara","Az&eacute;ri","Bachkir","Bi&eacute;lorusse",
  "Bulgare","Bihari","B&ecirc;che-De-Mer","Bengali","Tib&eacute;tain",
  "Breton","Catalan","Corse","Tch&egrave;que","Gallois",
  "Danois","Allemand","Boutani","Grec","Anglais",
  "Esp&eacute;ranto","Espagnol","Estonien","Basque","Persan",
  "Finnois","Fidjien","F&eacute;ro&iuml;en","Fran&ccedil;ais","Frison",
  "Ga&eacute;lique Irlandais","Ga&eacute;lique &Eacute;cossais","Galicien","Guarani","Goudjarati",
  "Ga&eacute;lique de l'&Icirc;le de Man","Haoussa","H&eacute;breu","Hindi","Croate",
  "Hongrois","Arm&eacute;nien","Interlingua","Indon&eacute;sien","Interlingue",
  "Inupiak","Islandais","Italien","Inuktitut","Japonais",
  "Javanais","G&eacute;orgien","Kazakh","Groenlandais","Cambodgien",
  "Kannada","Cor&eacute;en","Cachemiri","Kurde","Cornique",
  "Kirghiz","Latin","Luxembourgeois","Lingala","Lao",
  "Lithuanien","Letton","Malgache","Maori","Mac&eacute;donien",
  "Malayalam","Mongol","Moldave","Marathe","Malais",
  "Maltais","Birman","Nauri","N&eacute;palais","N&eacute;erlandais",
  "Norv&eacute;gien","Occitan","Oromo","Oriya","Pendjabi",
  "Polonais","Pachto","Portuguais","Quechua","Rh&eacute;to-Roman",
  "Roundi","Roumain","Russe","Rouanda","Sanscrit",
  "Sindhi","S&aacute;mi Du Nord","Sango","Serbo-Croate","Cingalais",
  "Slovaque","Slov&egrave;ne","Samoan","Chona","Somali",
  "Albanais","Serbe","Siswati","Sotho Du Sud","Soundanais",
  "Su&eacute;dois","Souah&eacute;li","Tamoul","T&eacute;lougou","Tadjik",
  "Tha&iuml;","Tigrigna","Turkm&egrave;ne","Tagal","Setchwana",
  "Kitonga","Turc","Tsonga","Tatar","Tchi",
  "Ou&iuml;gour","Ukrainien","Ourdou","Ouzbek","Vietnamien",
  "Volap&uuml;k","Ouolof","Xhosa","Yidich","Yorouba",
  "Tchouang","Chinois","Zoulou");

// --- Fonctions ---

// retourne le code ISO de la langue du navigateur
function obtenirCodeLangueNavig() {
  var lct="en";
  if (navigator.language) {
    lct=navigator.language.toLowerCase().substring(02);
  else if (navigator.userLanguage) {
    lct=navigator.userLanguage.toLowerCase().substring(02);
  else if (navigator.userAgent.indexOf("[")!=-1) {
    var debut=navigator.userAgent.indexOf("[");
    var fin=navigator.userAgent.indexOf("]");
    lct=navigator.userAgent.substring(debut+1, fin).toLowerCase();
  }
  return lct;
// fin obtenirCodeLangueNavig()

// retourne la langue en francais correspondant au code de langue specifie
function obtenirLangue(code) {
  if ((!code|| (code.length<2))
    return "";
  code=code.toLowerCase().substring(02);
  for (var i=0; i<langue_tabct.length; i++) {
    if (langue_tabct[i]==code)
      return(langue_tablg[i]);
  }
  return "";
// fin obtenirLangue(code)

// retourne la langue du navigateur en francais
function obtenirLangueNavig() {
  return (obtenirLangue(obtenirCodeLangueNavig()));
// fin obtenirLangueNavig()

    </SCRIPT>
  </HEAD>

  <BODY>
    <H1>JsLib 1.3</H1>
    <HR>
    <H2>Exemple - langue.js</H2>

    <NOSCRIPT>
      <P><I>Erreur : votre navigateur ne reconna&icirc;t pas le Javascript ou est configur&eacute; pour ne
      pas prendre en compte le code Javascript. Dans ce dernier cas, vous pouvez modifier la
      configuration dans les pr&eacute;f&eacute;rences/options de votre navigateur.</I>
      <HR>
    </NOSCRIPT>

    <P>Code de la langue de votre navigateur :
      <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">document.write(obtenirCodeLangueNavig())</SCRIPT>

    <P>Langue de votre navigateur :
      <SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">document.write(obtenirLangueNavig())</SCRIPT>

    <P>Langue pour un code de langue :
      <FORM ACTION="GET" NAME="f">
        <TABLE SUMMARY="formulaire" BORDER=CELLSPACING=CELLPADDING=2>
          <TR><TD>
            Code :
          </TD><TD>
            <INPUT NAME="t1" TYPE="text" SIZE="30" MAXLENGTH="2" VALUE="zu">
            <INPUT NAME="b1" TYPE="button" VALUE="Rechercher"
              onClick="this.form.t2.value=obtenirLangue(this.form.t1.value)">
          </TD></TR><TR><TD>
            Langue :
          </TD><TD>
             <INPUT NAME="t2" TYPE="text" SIZE="30" VALUE="">
          </TD></TR>
        </TABLE>
      </FORM>
      
  </BODY>
</HTML>



           
         
  
Related examples in the same category
1. Detects the browser, its version and the operating system of the client
2. Indentify your browser
3. Navigator:detect the client's browser
4. More details about the client's browser
5. All details about the client's browser
6. Browser infomation
7. Accessing the Properties of the navigator Object
8. Writing Different Text to a Page Based on the Browser
9.  Navigator Object
10. Using Navigator Properties
11. Functions to Examine Browsers
12. Get Browser version
13. Methods and Properties of the Frame Object
14. The Methods and Properties of the navigator Object
15. Verify browser language
16. Is cookie Enabled
17. document.alinkColor
18. document.lastModified
19. document.title
20. document.bgColor
21. document.fgColor
22. document.linkColor
23. document.vlinkColor
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.