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

Posted zengjf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Uncaught TypeError: jQuery.i18n.browserLang is not a function相关的知识,希望对你有一定的参考价值。

/*********************************************************************
 *   Uncaught TypeError: jQuery.i18n.browserLang is not a function
 * 说明:
 *     使用jQuery.i18n.properties.js来做语言自动转换,结果函数无效,读
 * 了一下插件源代码,发现已经换掉了接口名称、功能。
 *
 *                                   2017-8-28 深圳 龙华樟坑村 曾剑锋
 ********************************************************************/

一、参考文档:
    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. 不同版本,需要不同的调整;

 

以上是关于Uncaught TypeError: jQuery.i18n.browserLang is not a function的主要内容,如果未能解决你的问题,请参考以下文章

Uncaught (in promise) TypeError: Cannot read properties of null (reading 'fingerprint') Laravel Live

如何解决问题:Uncaught (in promise) TypeError: promisify is not a function?

Uncaught TypeError

Uncaught TypeError: Cannot redefine property: $router

Uncaught TypeError: o.block is not a function

Laravel 5.1 和 Vue.js - 21678 Uncaught (in promise) TypeError: Cannot read property 'data' of null