Javascript 带有新jQuery插件的本地化jQuery插件

Javascript 带有新jQuery插件的本地化jQuery插件,javascript,jquery,localization,Javascript,Jquery,Localization,我在我的多语言网站中使用不同的jQuery插件。当访问者更改语言时,jQuery插件中的变量必须更改为所选语言。同时,每个jQuery插件都是一个单独的文件。我编写了一个新的jQuery插件,名为jQuery.lang.js,如下所示: (function($) { translations: [] $.fn.Lang = function(method) { if (methods[method]) { return methods[me

我在我的多语言网站中使用不同的jQuery插件。当访问者更改语言时,jQuery插件中的变量必须更改为所选语言。同时,每个jQuery插件都是一个单独的文件。我编写了一个新的jQuery插件,名为jQuery.lang.js,如下所示:

(function($) {
    translations: []
    $.fn.Lang = function(method) {
        if (methods[method]) {
            return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
        } else if (typeof method === 'object' || !method) {
            return methods.init.apply(this, arguments);
        } else {
            $.error('Method ' + method + ' does not exist on jQuery.Lang');
        }

    };
    $.Lang.translations['en'] = {
        "vegetable" : {
            "spinach" : "Spinach",
            "marrow" : "Marrow"
        },
        "fruit" : {
            "apple" : "Apple",
            "grape" : "Grape"
        },
        "color" : {
            "red" : "Red",
            "blue" : "Blue"
        }
    }

    $.Lang.translations['tr'] = {
        "vegetable" : {
            "spinach" : "Ispanak",
            "marrow" : "Kabak"
        },
        "fruit" : {
            "apple" : "Elma",
            "grape" : "Üzüm"
        },
        "color" : {
            "red" : "Kırmızı",
            "blue" : "Mavi"
        }
    }
    // <html lang="tr">
    var currentLanguage = $("html").attr("lang");
    if (typeof $.Lang.translations[currentLanguage] !== 'undefined') $.Lang.row = $.Lang.translations[currentLanguage]; 
})(jQuery);

您可以认为蔬菜、水果和颜色是位于不同文件中的jQuery插件。我把它放在页面的顶部,在jquery.js文件下。我将jquery.fruit.js中的apple变量更改为$.Lang.row.apple。但它没有起作用。我不知道我在做什么。你能帮我吗?

你说它不起作用是什么意思?我不知道是什么错误。但即使是页面设计也被破坏了。你有没有在控制台中查找错误?我不知道它是如何使用的?在任何浏览器中单击F12键以打开开发人员工具。控制台就是这些工具之一。