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 ; }); }; } //$(document).ready(function () { // $("[data-localizable]").each(function (index, elem) { // var element = $(elem); // var attr = element.attr("data-localizable"); // var options = attr.split(':'); // if (options.length === 0) // return; // var resourceKey = options[options.length - 1]; // var resourceSet = options.length === 1 // ? window.location.replace(/^(?:\/\/|[^\/]+)*\//, "") // : options[0]; // localization.getResourceValue(resourceSet, resourceKey, function(result) { // if (result) // element.text(result); // }); // }); //})