i18n.js 387 Bytes
Newer Older
1 2
window.gettext = function(s){return s;};
window.ngettext = function(singular, plural, num){ return num == 1 ? singular : plural }
3 4 5 6 7 8 9 10

function interpolate(fmt, obj, named) {
    if (named) {
        return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
    } else {
        return fmt.replace(/%s/g, function(match){return String(obj.shift())});
    }
}