Sha256: 0a7d5be03cd47eba1175b91ace1d93a09534b4eaa1776e8088b1513ea8f6914d
Contents?: true
Size: 1.03 KB
Versions: 9
Compression:
Stored size: 1.03 KB
Contents
// Very simple i18n plugin // Written by Daniel Mendler (function($) { "use strict"; var locale = null, translations = {}; $.translations = function(t) { for (var lang in t) { if (!translations[lang]) { translations[lang] = t[lang]; } else { for (var name in t[lang]) { translations[lang][name] = t[lang][name]; } } } }; function lookup(locale, name) { var t = translations[locale]; return t && t[name]; } $.t = function(name, args) { if (!locale) { var html = $('html'); locale = html.attr('lang') || html.attr('xml:lang') || 'en'; } var i, s = lookup(locale, name); if (!s && (i = locale.indexOf('-'))) { s = lookup(locale.substr(0, i), name); } if (s) { for (var key in args) { s = s.replace(new RegExp('#{' + key + '}', 'g'), args[key]); } return s; } return '#' + name; }; })(jQuery);
Version data entries
9 entries across 9 versions & 1 rubygems