var importPoContent = function(callback) { var allcontentssplit = poContent.split(/\r?\n\s*\r?\n/); var alllabels = []; for (var i=0; i<allcontentssplit.length; i++) { var newstr = allcontentssplit[i].trim(); if (newstr != '') { var iscomment = false; var thepath = newstr.match(/path\: .*/) == null ? iscomment = true : newstr.match(/path\: .*/)[0].replace('path: ', '').trim() ; var thecode = newstr.match(/code\: .*/) == null ? iscomment = true : newstr.match(/code\: .*/)[0].replace('code: ', '').trim() ; var thekey = newstr.match(/key\: .*/) == null ? iscomment = true : newstr.match(/key\: .*/)[0].replace('key: ', '').trim() ; var thestr = newstr.match(/(?:msgstr ")(.*)(?:"$)/) == null ? iscomment = true : newstr.match(/(?:msgstr ")(.*)(?:"$)/)[1].trim() ; if (!iscomment) { // Add/Update the label db.dbLabelUpdate(thepath, thecode, thekey, thestr, skipExisting); alllabels.push({ 'path': thepath, 'lang': thecode, 'key': thekey, 'text': thestr }); } } } // Populate any missing languge labels with placeholders db.dbLabelExists(alllabels, callback); }
var importPoContent = function(callback) { var db = require(__appdevPath+'/install/db/db_'+AD.Defaults.dataStoreMethod+'.js'); var allcontentssplit = poContent.split(/(\r\n|\r|\n)\s*(\r\n|\r|\n)/); var alllabels = []; for (var i=0; i<allcontentssplit.length; i++) { var newstr = allcontentssplit[i].trim(); if (newstr != '') { var iscomment = false; var thepath = newstr.match(/path\: .*/) == null ? iscomment = true : newstr.match(/path\: .*/)[0].replace('path: ', '').trim() ; var thecode = newstr.match(/code\: .*/) == null ? iscomment = true : newstr.match(/code\: .*/)[0].replace('code: ', '').trim() ; var thekey = newstr.match(/key\: .*/) == null ? iscomment = true : newstr.match(/key\: .*/)[0].replace('key: ', '').trim() ; var thestr = newstr.match(/(?:msgstr ")(.*)(?:"$)/) == null ? iscomment = true : newstr.match(/(?:msgstr ")(.*)(?:"$)/)[1].trim() ; if (!iscomment) { // Add/Update the label db.dbLabelUpdate(thepath, thecode, thekey, thestr); alllabels.push({ 'path': thepath, 'lang': thecode, 'key': thekey, 'text': thestr }); } } } // Populate any missing languge labels with placeholders db.dbLabelExists(alllabels, callback); }