/********************************************************************* * ??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
原文地址:http://www.cnblogs.com/zengjfgit/p/7457524.html