jQuery 自动识别浏览器语言

2019PHP高薪工程师学习路线图....>>>

(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);