var localization = { getResourceSet: function (resourceSet) { var resoures; $.ajax({ url: "/localization/localizeset", data: "resourceSet=" + resourceSet, type: 'GET', async: false, cache: false, success: function(results) { resoures = results; $.extend(resoures, { getValue: function(resouceKey, defaultValue) { var value = resoures[resouceKey]; if (value) return value; else return defaultValue; } }); }, error: function(error) { resoures = null; } }); return resoures; }, getResourceValue: function(resourceSet, resourceKey, callback) { return $.get("/localization/localizevalue?resourceSet=" + resourceSet + "&resourceKey=" + resourceKey, callback); } }; if (!String.prototype.format) { String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; }