lib/gettext.js
function (d, msgctxt, msgid, msgid_plural, n, category) {
        if (! msgid) {
            return '';
        }

        var msg_ctxt_id = msgctxt ? msgctxt + this.context_glue + msgid : msgid;

        var domainname = d || this.domain || 'messages';
        var lang = this.lang;

        // category is always LC_MESSAGES. We ignore all else
        var category_name = 'LC_MESSAGES';
        category = 5;

        var locale_data = [];
        if (typeof(this.data[lang]) != 'undefined' &&
            this.data[lang][domainname]) {
                locale_data.push(this.data[lang][domainname] );

        } else if (typeof(this.data[lang]) != 'undefined') {
            // didn't find domain we're looking for. Search all of them.
            for (var dom in this.data[lang]) {
                locale_data.push(this.data[lang][dom] );
            }
        }

        var trans = [];
        var found = false;
        var domain_used; // so we can find plural-forms if needed
        if (locale_data.length) {
            for (var i=0; i<locale_data.length; i++) {
                var locale = locale_data[i];
                if (locale.msgs[msg_ctxt_id]) {
                    var msg_ctxt_str = locale.msgs[msg_ctxt_id].msgstr;
                    trans = msg_ctxt_str.concat(trans.slice(msg_ctxt_str.length));
                    domain_used = locale;
                    found = true;
                    // only break if found translation actually has a translation.
                    if ( trans.length > 0 && trans[0].length !== 0 ) {
                        break;
                    }
                }
            }
        }

        // default to english if we lack a match, or match has zero length
        if ( trans.length === 0 || trans[0].length === 0 ) {
            trans = [ msgid, msgid_plural ];
        }

        var translation = trans[0];
        if (msgid_plural) {
            var p;
            if (found && domain_used.head.plural_func) {
                var rv = domain_used.head.plural_func(n);
                if (! rv.plural) {
                    rv.plural = 0;
                }
                if (! rv.nplural) {
                    rv.nplural = 0;
                }
                // if plurals returned is out of bound for total plural forms
                if (rv.nplural <= rv.plural) {
                    rv.plural = 0;
                }
                p = rv.plural;
            } else {
                p = (n != 1) ? 1 : 0;
            }
            if (trans[p]) {
                translation = trans[p];
            }
        }

        return translation;
    }
function (d, msgctxt, msgid, msgid_plural, n, category) {
        if (! msgid) {
            return '';
        }

        var msg_ctxt_id = msgctxt ? msgctxt + this.context_glue + msgid : msgid;

        var domainname = d || this.domain || 'messages';
        var lang = this.lang;

        // category is always LC_MESSAGES. We ignore all else
        var category_name = 'LC_MESSAGES';
        category = 5;

        var locale_data = [];
        if (typeof(this.data[lang]) != 'undefined' &&
            this.data[lang][domainname]) {
                locale_data.push(this.data[lang][domainname] );

        } else if (typeof(this.data[lang]) != 'undefined') {
            // didn't find domain we're looking for. Search all of them.
            for (var dom in this.data[lang]) {
                locale_data.push(this.data[lang][dom] );
            }
        }

        var trans = [];
        var found = false;
        var domain_used; // so we can find plural-forms if needed
        if (locale_data.length) {
            for (var i=0; i<locale_data.length; i++) {
                var locale = locale_data[i];
                if (locale.msgs[msg_ctxt_id]) {
                    var msg_ctxt_str = locale.msgs[msg_ctxt_id].msgstr;
                    trans = msg_ctxt_str.concat(trans.slice(msg_ctxt_str.length));
                    domain_used = locale;
                    found = true;
                    // only break if found translation actually has a translation.
                    if ( trans.length > 0 && trans[0].length !== 0 ) {
                        break;
                    }
                }
            }
        }

        // default to english if we lack a match, or match has zero length
        if ( trans.length === 0 || trans[0].length === 0 ) {
            trans = [ msgid, msgid_plural ];
        }

        var translation = trans[0];
        if (msgid_plural) {
            var p;
            if (found && domain_used.head.plural_func) {
                var rv = domain_used.head.plural_func(n);
                if (! rv.plural) {
                    rv.plural = 0;
                }
                if (! rv.nplural) {
                    rv.nplural = 0;
                }
                // if plurals returned is out of bound for total plural forms
                if (rv.nplural <= rv.plural) {
                    rv.plural = 0;
                }
                p = rv.plural;
            } else {
                p = (n != 1) ? 1 : 0;
            }
            if (trans[p]) {
                translation = trans[p];
            }
        }

        return translation;
    }
function ( d , msgctxt , msgid , msgid_plural , n , category ) { if ( ! msgid ) { return '' ; } var msg_ctxt_id = msgctxt ? msgctxt + this . context_glue + msgid : msgid ; var domainname = d || this . domain || 'messages' ; var lang = this . lang ; // category is always LC_MESSAGES. We ignore all else var category_name = 'LC_MESSAGES' ; category = 5 ; var locale_data = [ ] ; if ( typeof ( this . data [ lang ] ) != 'undefined' && this . data [ lang ] [ domainname ] ) { locale_data . push ( this . data [ lang ] [ domainname ] ) ; } else if ( typeof ( this . data [ lang ] ) != 'undefined' ) { // didn't find domain we're looking for. Search all of them. for ( var dom in this . data [ lang ] ) { locale_data . push ( this . data [ lang ] [ dom ] ) ; } } var trans = [ ] ; var found = false ; var domain_used ; // so we can find plural-forms if needed if ( locale_data . length ) { for ( var i = 0 ; i < locale_data . length ; i ++ ) { var locale = locale_data [ i ] ; if ( locale . msgs [ msg_ctxt_id ] ) { var msg_ctxt_str = locale . msgs [ msg_ctxt_id ] . msgstr ; trans = msg_ctxt_str . concat ( trans . slice ( msg_ctxt_str . length ) ) ; domain_used = locale ; found = true ; // only break if found translation actually has a translation. if ( trans . length > 0 && trans [ 0 ] . length !== 0 ) { break ; } } } } // default to english if we lack a match, or match has zero length if ( trans . length === 0 || trans [ 0 ] . length === 0 ) { trans = [ msgid , msgid_plural ] ; } var translation = trans [ 0 ] ; if ( msgid_plural ) { var p ; if ( found && domain_used . head . plural_func ) { var rv = domain_used . head . plural_func ( n ) ; if ( ! rv . plural ) { rv . plural = 0 ; } if ( ! rv . nplural ) { rv . nplural = 0 ; } // if plurals returned is out of bound for total plural forms if ( rv . nplural <= rv . plural ) { rv . plural = 0 ; } p = rv . plural ; } else { p = ( n != 1 ) ? 1 : 0 ; } if ( trans [ p ] ) { translation = trans [ p ] ; } } return translation ; }
this has all the options, so we use it for all of them.
this has all the options so we use it for all of them .