jQuery 自动识别浏览器语言

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

(function($){
//
// DIV must be style="display:none;"    
//
$.fn.chk_userlanguage = function() {
    /* check if <style=display:none;> not set to that element */
    if (!this.is(":hidden")) { this.hide(); };

    /* get browser default lang */ 
    if (navigator.userLanguage) {
        baseLang = navigator.userLanguage.substring(0,2).toLowerCase();
    } else {
        baseLang = navigator.language.substring(0,2).toLowerCase();
    }

    /* language match */
    switch(baseLang)
    {
        case "de":
            /* german */
            this.slideDown("slow");
            break;
        case "en":
            /* english */
            break;
        case "ja":
            /* japanese */
            break;
        case "zh":
            /* 中文 */
            break;
        default:
            /* default no match */
    }
};  
})(jQuery);