lib/main.js
function(data, onProgress) {
        onProgress = onProgress || function() {};
        return new Promise(function(resolve, reject) {
            try {
                let languages = JSON.parse(data);
                _.forEach(languages, function (language, index) {
                    language.slug = language.lc;
                    language.name = language.ln;
                    language.anglicized_name = language.ang;
                    language.direction = language.ld;
                    language.region = language.lr;
                    language.country_codes = language.cc || [];
                    language.aliases = language.alt || [];
                    language.is_gateway_language = language.gl ? language.gl : false;

                    try {
                        library.addTargetLanguage(language);
                    } catch (err) {
                        console.error('Failed to add target language', language);
                        reject(err);
                        return;
                    }
                    onProgress(languages.length, index + 1);
                });
                resolve();
            } catch(err) {
                reject(err);
            }
        });
    }
function(data, onProgress) {
        onProgress = onProgress || function() {};
        return new Promise(function(resolve, reject) {
            try {
                let languages = JSON.parse(data);
                _.forEach(languages, function (language, index) {
                    language.slug = language.lc;
                    language.name = language.ln;
                    language.anglicized_name = language.ang;
                    language.direction = language.ld;
                    language.region = language.lr;
                    language.country_codes = language.cc || [];
                    language.aliases = language.alt || [];
                    language.is_gateway_language = language.gl ? language.gl : false;

                    try {
                        library.addTargetLanguage(language);
                    } catch (err) {
                        console.error('Failed to add target language', language);
                        reject(err);
                        return;
                    }
                    onProgress(languages.length, index + 1);
                });
                resolve();
            } catch(err) {
                reject(err);
            }
        });
    }
function ( data , onProgress ) { onProgress = onProgress || function ( ) { } ; return new Promise ( function ( resolve , reject ) { try { let languages = JSON . parse ( data ) ; _ . forEach ( languages , function ( language , index ) { language . slug = language . lc ; language . name = language . ln ; language . anglicized_name = language . ang ; language . direction = language . ld ; language . region = language . lr ; language . country_codes = language . cc || [ ] ; language . aliases = language . alt || [ ] ; language . is_gateway_language = language . gl ? language . gl : false ; try { library . addTargetLanguage ( language ) ; } catch ( err ) { console . error ( 'Failed to add target language' , language ) ; reject ( err ) ; return ; } onProgress ( languages . length , index + 1 ) ; } ) ; resolve ( ) ; } catch ( err ) { reject ( err ) ; } } ) ; }
Parses the target language catalog and indexes it.

@param data {string}
@param onProgress {function} an optional progress listener. This should receive progress id, total, completed
@returns {Promise}
Parses the target language catalog and indexes it .