lib/library.js
function(language_slug, project_slug, resource_slug, resource_type, translate_mode, min_checking_level, max_checking_level) {
            let condition_max_checking = '';

            language_slug = language_slug || '%';
            project_slug = project_slug || '%';
            resource_slug = resource_slug || '%';
            resource_type = resource_type || '%';
            translate_mode = translate_mode || '%';
            min_checking_level = min_checking_level || 0;
            max_checking_level = max_checking_level || -1;

            if(max_checking_level >= 0) condition_max_checking = ' and r.checking_level <= ' + max_checking_level;

            let translations = [];
            let results = query("select l.slug as language_slug, l.name as language_name, l.direction," +
                " p.slug as project_slug, p.category_id, p.name as project_name, p.desc, p.icon, p.sort, p.chunks_url," +
                " r.id as resource_id, r.slug as resource_slug, r.name as resource_name, r.type, r.translate_mode, r.checking_level, r.comments, r.pub_date, r.license, r.version," +
                " lri.translation_words_assignments_url," +
                " c.slug as category_slug " +
                " from source_language as l" +
                " left join project as p on p.source_language_id=l.id" +
                " left join resource as r on r.project_id=p.id" +
                " left join legacy_resource_info as lri on lri.resource_id=r.id" +
                " left join category as c on c.id=p.category_id" +
                " where l.slug like(?) and p.slug like(?) and r.slug like(?)" +
                " and r.checking_level >= ?" +
                condition_max_checking +
                " and r.type like(?) and r.translate_mode like(?)", [language_slug, project_slug, resource_slug, min_checking_level, resource_type, translate_mode]);

            for(let r of results) {
                let trans = {
                    language: {
                        slug: r.language_slug,
                        name: r.language_name,
                        direction: r.direction
                    },
                    project: {
                        slug: r.project_slug,
                        name: r.project_name,
                        desc: r.desc,
                        sort: r.sort,
                        icon: r.icon,
                        chunks_url: r.chunks_url,
                        source_language_slug: r.language_slug,
                        category_id: r.category_id,
                        category_slug: r.category_slug
                    },
                    resource: {
                        slug: r.resource_slug,
                        name: r.resource_name,
                        type: r.type,
                        status: {
                            translate_mode: r.translate_mode,
                            checking_level: r.checking_level,
                            comments: r.comments,
                            pub_date: r.pub_date,
                            license: r.license,
                            version: r.version
                        },
                        project_slug: r.project_slug,
                        source_language_slug: r.language_slug
                    }
                };

                // load formats and add to resource
                let formats = [];
                let formatResults =  query('select * from resource_format' +
                    ' where resource_id=?', [r.resource_id]);
                let imported = false;
                for(let f of formatResults) {
                    delete f.id;
                    delete f.resource_id;
                    f.imported = !!f.imported;
                    formats.push(f);
                    // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly
                    if(f.imported) imported = true;
                }
                trans.resource.formats = formats;
                trans.resource.imported = imported;

                translations.push(trans);
            }
            return translations;
        }
function(language_slug, project_slug, resource_slug, resource_type, translate_mode, min_checking_level, max_checking_level) {
            let condition_max_checking = '';

            language_slug = language_slug || '%';
            project_slug = project_slug || '%';
            resource_slug = resource_slug || '%';
            resource_type = resource_type || '%';
            translate_mode = translate_mode || '%';
            min_checking_level = min_checking_level || 0;
            max_checking_level = max_checking_level || -1;

            if(max_checking_level >= 0) condition_max_checking = ' and r.checking_level <= ' + max_checking_level;

            let translations = [];
            let results = query("select l.slug as language_slug, l.name as language_name, l.direction," +
                " p.slug as project_slug, p.category_id, p.name as project_name, p.desc, p.icon, p.sort, p.chunks_url," +
                " r.id as resource_id, r.slug as resource_slug, r.name as resource_name, r.type, r.translate_mode, r.checking_level, r.comments, r.pub_date, r.license, r.version," +
                " lri.translation_words_assignments_url," +
                " c.slug as category_slug " +
                " from source_language as l" +
                " left join project as p on p.source_language_id=l.id" +
                " left join resource as r on r.project_id=p.id" +
                " left join legacy_resource_info as lri on lri.resource_id=r.id" +
                " left join category as c on c.id=p.category_id" +
                " where l.slug like(?) and p.slug like(?) and r.slug like(?)" +
                " and r.checking_level >= ?" +
                condition_max_checking +
                " and r.type like(?) and r.translate_mode like(?)", [language_slug, project_slug, resource_slug, min_checking_level, resource_type, translate_mode]);

            for(let r of results) {
                let trans = {
                    language: {
                        slug: r.language_slug,
                        name: r.language_name,
                        direction: r.direction
                    },
                    project: {
                        slug: r.project_slug,
                        name: r.project_name,
                        desc: r.desc,
                        sort: r.sort,
                        icon: r.icon,
                        chunks_url: r.chunks_url,
                        source_language_slug: r.language_slug,
                        category_id: r.category_id,
                        category_slug: r.category_slug
                    },
                    resource: {
                        slug: r.resource_slug,
                        name: r.resource_name,
                        type: r.type,
                        status: {
                            translate_mode: r.translate_mode,
                            checking_level: r.checking_level,
                            comments: r.comments,
                            pub_date: r.pub_date,
                            license: r.license,
                            version: r.version
                        },
                        project_slug: r.project_slug,
                        source_language_slug: r.language_slug
                    }
                };

                // load formats and add to resource
                let formats = [];
                let formatResults =  query('select * from resource_format' +
                    ' where resource_id=?', [r.resource_id]);
                let imported = false;
                for(let f of formatResults) {
                    delete f.id;
                    delete f.resource_id;
                    f.imported = !!f.imported;
                    formats.push(f);
                    // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly
                    if(f.imported) imported = true;
                }
                trans.resource.formats = formats;
                trans.resource.imported = imported;

                translations.push(trans);
            }
            return translations;
        }
function ( language_slug , project_slug , resource_slug , resource_type , translate_mode , min_checking_level , max_checking_level ) { let condition_max_checking = '' ; language_slug = language_slug || '%' ; project_slug = project_slug || '%' ; resource_slug = resource_slug || '%' ; resource_type = resource_type || '%' ; translate_mode = translate_mode || '%' ; min_checking_level = min_checking_level || 0 ; max_checking_level = max_checking_level || - 1 ; if ( max_checking_level >= 0 ) condition_max_checking = ' and r.checking_level <= ' + max_checking_level ; let translations = [ ] ; let results = query ( "select l.slug as language_slug, l.name as language_name, l.direction," + " p.slug as project_slug, p.category_id, p.name as project_name, p.desc, p.icon, p.sort, p.chunks_url," + " r.id as resource_id, r.slug as resource_slug, r.name as resource_name, r.type, r.translate_mode, r.checking_level, r.comments, r.pub_date, r.license, r.version," + " lri.translation_words_assignments_url," + " c.slug as category_slug " + " from source_language as l" + " left join project as p on p.source_language_id=l.id" + " left join resource as r on r.project_id=p.id" + " left join legacy_resource_info as lri on lri.resource_id=r.id" + " left join category as c on c.id=p.category_id" + " where l.slug like(?) and p.slug like(?) and r.slug like(?)" + " and r.checking_level >= ?" + condition_max_checking + " and r.type like(?) and r.translate_mode like(?)" , [ language_slug , project_slug , resource_slug , min_checking_level , resource_type , translate_mode ] ) ; for ( let r of results ) { let trans = { language : { slug : r . language_slug , name : r . language_name , direction : r . direction } , project : { slug : r . project_slug , name : r . project_name , desc : r . desc , sort : r . sort , icon : r . icon , chunks_url : r . chunks_url , source_language_slug : r . language_slug , category_id : r . category_id , category_slug : r . category_slug } , resource : { slug : r . resource_slug , name : r . resource_name , type : r . type , status : { translate_mode : r . translate_mode , checking_level : r . checking_level , comments : r . comments , pub_date : r . pub_date , license : r . license , version : r . version } , project_slug : r . project_slug , source_language_slug : r . language_slug } } ; // load formats and add to resource let formats = [ ] ; let formatResults = query ( 'select * from resource_format' + ' where resource_id=?' , [ r . resource_id ] ) ; let imported = false ; for ( let f of formatResults ) { delete f . id ; delete f . resource_id ; f . imported = ! ! f . imported ; formats . push ( f ) ; // TRICKY: this is not technically correct, but for convenience we attach the import status to the resource directly if ( f . imported ) imported = true ; } trans . resource . formats = formats ; trans . resource . imported = imported ; translations . push ( trans ) ; } return translations ; }
Return sa list of translations.

@param language_slug string the language these translations are available in. Leave null for all.
@param project_slug string the project for whom these translations are available. Leave null for all.
@param resource_slug string the resource for whom these translations are available. Leave null for all.
@param resource_type string the resource type allowed for returned translations. Leave null for all.
@param translate_mode string limit results to just those with the given translate mode. Leave null for all.
@param min_checking_level int the minimum checking level allowed for returned translations. Use 0 for no minimum.
@param max_checking_level int the maximum checking level allowed for returned translations. Use -1 for no maximum.
Return sa list of translations .