Identification of Languages selected in the browser

Go to Languages tutorial home

The script bellow will identify the languages selected in the browser of the visitor, and the information will be processed before responding to the browser.

  1. We will save in variable TheLanguages the informatiuon obtained from the browser. TheLanguages is an array containing all the lenguages (p.e: TheLanguages(0)="en", TheLanguages(0)="es" etc).
  2. We will calculate the number of languages (Numberoflanguages: value for this variable will be 0 if only one language is selected in the browser, 1 if two languages are selected etc).
  3. For each language in array TheLanguages we will run Subroutine WriteLanguage.
  4. In subroutine WriteLanguage the script will write the name of the language.
<%
TheLanguages=split (Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"),",")  

Numberoflanguages=ubound(TheLanguages)

response.write("The languages selected in your browser:<BR>") 
for i=0 to Numberoflanguages
 if Instr(TheLanguages(i),";") then 
  TheLanguages(i)=Mid(TheLanguages(i), 1,Instr(TheLanguages(i),";")-1)
  end if
    WriteLanguage(TheLanguages(i))
    response.write("<BR>") 
next
%>
 

<% 
Sub WriteLanguage(Languagetowrite)

Select Case Languagetowrite 
Case "af"
  Response.write("Afrikaans")
Case "sq"
  Response.write("Albanian")
Case "eu"
  Response.write("Basque")
Case "bg"
  Response.write("Bulgarian")
Case "be"
  Response.write("Byelorussian")
Case "ca"
  Response.write("Catalan")
Case "zh"
  Response.write("Chinese")
Case "zh-cn"
  Response.write("Chinese/China")
Case "zh-tw"
  Response.write("Chinese/Taiwan")
Case "zh-hk"
  Response.write("Chinese/Hong Kong")
Case "zh-sg"
  Response.write("Chinese/singapore")
Case "hr"
  Response.write("Croatian")
Case "cs"
  Response.write("Czech")
Case "da"
  Response.write("Danish")
Case "nl"
  Response.write("Dutch")
Case "nl-be"
  Response.write("Dutch/Belgium")
Case "en"
  Response.write("English")
Case "en-gb"
  Response.write("English/United Kingdom")
Case "en-us"
  Response.write("English/United Satates")
Case "en-au"
  Response.write("English/Australian")
Case "en-ca"
  Response.write("English/Canada")
Case "en-nz"
  Response.write("English/New Zealand")
Case "en-ie"
  Response.write("English/Ireland")
Case "en-za"
  Response.write("English/South Africa")
Case "en-jm"
  Response.write("English/Jamaica")
Case "en-bz"
  Response.write("English/Belize")
Case "en-tt"
  Response.write("English/Trinidad")
Case "et"
  Response.write("Estonian")
Case "fo"
  Response.write("Faeroese")
Case "fa"
  Response.write("Farsi")
Case "fi"
  Response.write("Finnish")
Case "fr"
  Response.write("French")
Case "fr-be"
  Response.write("French/Belgium")
Case "fr-fr"
  Response.write("French/France")
Case "fr-ch"
  Response.write("French/Switzerland")
Case "fr-ca"
  Response.write("French/Canada")
Case "fr-lu"
  Response.write("French/Luxembourg")
Case "gd"
  Response.write("Gaelic")
Case "gl"
  Response.write("Galician")
Case "de"
  Response.write("German")
Case "de-at"
  Response.write("German/Austria")
Case "de-de"
  Response.write("German/Germany")
Case "de-ch"
  Response.write("German/Switzerland")
Case "de-lu"
  Response.write("German/Luxembourg")
Case "de-li"
  Response.write("German/Liechtenstein")
Case "el"
  Response.write("Greek")
Case "hi"
  Response.write("Hindi")
Case "hu"
  Response.write("Hungarian")
Case "is"
  Response.write("Icelandic")
Case "id"
  Response.write("Indonesian")
Case "in"
  Response.write("Indonesian")
Case "ga"
  Response.write("Irish")
Case "it"
  Response.write("Italian")
Case "it-ch"
  Response.write("Italian/ Switzerland")
Case "ja"
  Response.write("Japanese")
Case "ko"
  Response.write("Korean")
Case "lv"
  Response.write("Latvian")
Case "lt"
  Response.write("Lithuanian")
Case "mk"
  Response.write("Macedonian")
Case "ms"
  Response.write("Malaysian")
Case "mt"
  Response.write("Maltese")
Case "no"
  Response.write("Norwegian")
Case "pl"
  Response.write("Polish")
Case "pt"
  Response.write("Portuguese")
Case "pt-br"
  Response.write("Portuguese/Brazil")
Case "rm"
  Response.write("Rhaeto-Romanic")
Case "ro"
  Response.write("Romanian")
Case "ro-mo"
  Response.write("Romanian/Moldavia")
Case "ru"
  Response.write("Russian")
Case "ru-mo"
  Response.write("Russian /Moldavia")
Case "gd"
  Response.write("Scots Gaelic")
Case "sr"
  Response.write("Serbian")
Case "sk"
  Response.write("Slovack")
Case "sl"
  Response.write("Slovenian")
Case "sb"
  Response.write("Sorbian")
Case "es"
  Response.write("Spanish")
Case "es-do"
  Response.write("Spanish")
Case "es-ar"
  Response.write("Spanish/Argentina")
Case "es-co"
  Response.write("Spanish/Colombia")
Case "es-mx"
  Response.write("Spanish/Mexico")
Case "es-es"
  Response.write("Spanish/Spain")
Case "es-gt"
  Response.write("Spanish/Guatemala")
Case "es-cr"
  Response.write("Spanish/Costa Rica")
Case "es-pa"
  Response.write("Spanish/Panama")
Case "es-ve"
  Response.write("Spanish/Venezuela")
Case "es-pe"
  Response.write("Spanish/Peru")
Case "es-ec"
  Response.write("Spanish/Ecuador")
Case "es-cl"
  Response.write("Spanish/Chile")
Case "es-uy"
  Response.write("Spanish/Uruguay")
Case "es-py"
  Response.write("Spanish/Paraguay")
Case "es-bo"
  Response.write("Spanish/Bolivia")
Case "es-sv"
  Response.write("Spanish/El salvador")
Case "es-hn"
  Response.write("Spanish/Honduras")
Case "es-ni"
  Response.write("Spanish/Nicaragua")
Case "es-pr"
  Response.write("Spanish/Puerto Rico")
Case "sx"
  Response.write("Sutu")
Case "sv"
  Response.write("Swedish")
Case "sv-fi"
  Response.write("Swedish/Findland")
Case "ts"
  Response.write("Thai")
Case "tn"
  Response.write("Tswana")
Case "tr"
  Response.write("Turkish")
Case "uk"
  Response.write("Ukrainian")
Case "ur"
  Response.write("Urdu")
Case "vi"
  Response.write("Vietnamese")
Case "xh"
  Response.write("Xshosa")
Case "ji"
  Response.write("Yiddish")
Case "zu"
  Response.write("Zulu")
Case Else 
  Response.write (Languagetowrite & ": Language not identify")
End Select

End Sub
%>


 

AspTutorial.info.