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

Version Path
olelo-0.9.15 static/script/10-olelo.i18n.js
olelo-0.9.14 static/script/10-olelo.i18n.js
olelo-0.9.13 static/script/10-olelo.i18n.js
olelo-0.9.12 static/script/10-olelo.i18n.js
olelo-0.9.11 static/script/10-olelo.i18n.js
olelo-0.9.10 static/script/10-olelo.i18n.js
olelo-0.9.9 static/script/10-olelo.i18n.js
olelo-0.9.8 static/script/10-olelo.i18n.js
olelo-0.9.7 static/script/10-olelo.i18n.js