判断浏览器语言类型【亲测可用】兼容IE
实现不同语言转向不不同页面:
[code lang=”js”]
<script type="text/javascript">
var lang = navigator.language || navigator.userLanguage;
if (lang.indexOf(‘zh’) > -1) {
document.location.href = ‘chinese.html’;
} else{
document.location.href = ‘english.html’;}
</script>
[/code]
附各种语言简码:
各种语系的简称:
af Afrikaans sq Albanian
ar-sa Arabic(Saudi Arabia) ar-iq Arabic(Iraq)
ar-eg Arabic(Egypt) ar-ly Arabic(Libya)
ar-dz Arabic(Algeria) ar-ma Arabic(Morocco)
ar-tn Arabic(Tunisia) ar-om Arabic(Oman)
ar-ye Arabic(Yemen) ar-sy Arabic(Syria)
ar-jo Arabic(Jordan) ar-lb Arabic(Lebanon)
ar-kw Arabic(Kuwait) ar-ae Arabic(U.A.E.)
ar-bh Arabic(Bahrain) ar-qa Arabic(Qatar)
eu Basque bg Bulgarian
be Belarusian ca Catalan
zh-tw Chinese(Taiwan Region) zh-cn Chinese(PRC)
zh-hk Chinese(Hong Kong SAR,PRC) zh-sg Chinese(Singapore)
hr Croatian cs Czech
da Danish nl Dutch(Standard)
nl-be Dutch(Belgian) en English
en-us English(United States) en-gb English(British)
en-au English(Australian) en-ca English(Canadian)
en-nz English(New Zealand) en-ie English(Ireland)
en-za English(South Africa) en-jm English(Jamaica)
en English(Caribbean) en-bz English(Belize)
en-tt English(Trinidad) et Estonian
fo Faeroese fa Farsi
fi Finnish fr French(Standard)
fr-be French(Belgian) fr-ca French(Canadian)
fr-ch French(Swiss) fr-lu French(Luxembourg)
gd Gaelic(Scots) gd-ie Gaelic(Irish)
de German(Standard) de-ch German(Swiss)
de-at German(Austrian) de-lu German(Luxembourg)
de-li German(Liechtenstein) el Greek
he Hebrew hi Hindi
hu Hungarian is Icelandic
in Indonesian it Italian(Standard)
it-ch Italian(Swiss) ja Japanese
ko Korean ko Korean(Johab)
lv Latvian lt Lithuanian
mk Macedonian ms Malaysian
mt Maltese no Norwegian(Bokmal)
no Norwegian(Nynorsk) pl Polish
pt-br Portuguese(Brazilian) pt Portuguese(Standard)
rm Rhaeto-Romanic ro Romanian
ro-mo Romanian(Moldavia) ru Russian
ru-mo Russian(Moldavia) sz Sami(Lappish)
sr Serbian(Cyrillic) sr Serbian(Latin)
sk Slovak sl Slovenian
sb Sorbian es Spanish(Spain-Traditional Sort)
es-mx Spanish(Mexican) es Spanish(Spain-Modern Sort)
es-gt Spanish(Guatemala) es-cr Spanish(Costa Rica)
es-pa Spanish(Panama) es-do Spanish(Dominican Republic)
es-ve Spanish(Venezuela) es-co Spanish(Colombia)
es-pe Spanish(Peru) es-ar Spanish(Argentina)
es-ec Spanish(Ecuador) es-cl Spanish(Chile)
es-uy Spanish(Uruguay) es-py Spanish(Paraguay)
es-bo Spanish(Bolivia) es-sv Spanish(El Salvador)
es-hn Spanish(Honduras) es-ni Spanish(Nicaragua)
es-pr Spanish(Puerto Rico) sx Sutu
sv Swedish sv-fi Swedish(Finland)
th Thai ts Tsonga
tn Tswana tr Turkish
uk Ukrainian ur Urdu
ve Venda vi Vietnamese
xh Xhosa ji Yiddish
zu Zulu