• Uncaught TypeError: jQuery.i18n.browserLang is not a function


    /*********************************************************************
     *   Uncaught TypeError: jQuery.i18n.browserLang is not a function
     * 说明:
     *     使用jQuery.i18n.properties.js来做语言自动转换,结果函数无效,读
     * 了一下插件源代码,发现已经换掉了接口名称、功能。
     *
     *                                   2017-8-31 深圳 龙华樟坑村 曾剑锋
     ********************************************************************/
    
    一、参考文档:
        1. jQuery.i18n.properties.js
            https://github.com/jquery-i18n-properties/jquery-i18n-properties/blob/master/jquery.i18n.properties.js
    
    二、查看、分析源代码:
        1. 确实已经没有了browserLang处理函数了;
        2. 取而代之的是:  
            $.i18n.normaliseLanguageCode = function (settings) {
                var lang = settings.language;
                ...
            }
        3. 如上,需要传递一个json格式数据,有language字段;
        4. 处理方式:
            function nav_language_change(obj) {
                var language = "";
    
                if (obj == undefined ) {
                    language = $.i18n.normaliseLanguageCode({"language" : ""});
                } else {
                    language = obj.innerHTML.toString();
                    $.i18n.normaliseLanguageCode({"language": language});
                }
            
                current_language = language;
            
                // This will initialize the plugin 
                // and show two dialog boxes: one with the text "Olá World"
                // and other with the text "Good morning John!" 
                // How to dynamically change language using jquery-i18n-properties and JavaScript?
                //    https://stackoverflow.com/questions/15637059/how-to-dynamically-change-language-using-jquery-i18n-properties-and-javascript
                jQuery.i18n.properties({
                    name:'lang', 
                    path:'language/', 
                    mode:'both',
                    language: language,
                    async: true,
                    callback: function() {
                        ...
                    }
                });
            }
        5. 不同版本,需要不同的调整;
  • 相关阅读:
    2019春第三次课程设计实验报告
    2019春第二次课程设计实验报告
    2019春第一次课程设计实验报告
    第十二周总结
    第十一周总结
    第五周课程总结&试验报告(三)
    第四周课程总结&实验报告(二)
    第三周课程总结&实验报告一
    第二周学习总结
    19春总结
  • 原文地址:https://www.cnblogs.com/zengjfgit/p/7457524.html
Copyright © 2020-2023  润新知