scripts/create_android_strings.js
function processResult(context, lang, langJson, stringXmlJson) {
    var path = require('path');
    var q = require('q');
    var deferred = q.defer();

    var mapObj = {};
    // create a map to the actual string
    _.forEach(stringXmlJson.resources.string, function (val) {
        if (_.has(val, "$") && _.has(val["$"], "name")) {
            mapObj[val["$"].name] = val;
        }
    });

    var langJsonToProcess = _.assignIn(langJson.config_android, langJson.app, langJson.app_android);

    //now iterate through langJsonToProcess
    _.forEach(langJsonToProcess, function (val, key) {
        // positional string format is in Mac OS X format.  change to android format
        val = val.replace(/\$@/gi, "$s");
        val = val.replace(/\'/gi, "\\'");

        if (_.has(mapObj, key)) {
            // mapObj contains key. replace key
            mapObj[key]["_"] = val;
        } else {
            // add by inserting
            stringXmlJson.resources.string.push({
                _: val,
                '$': {name: key}
            });
        }
    });

    //save to disk
    var langDir = getLocalizationDir(context, lang);
    var filePath = getLocalStringXmlPath(context, lang);

    fs.ensureDir(langDir, function (err) {
        if (err) {
            throw err;
        }

        fs.writeFile(filePath, buildXML(stringXmlJson), {encoding: 'utf8'}, function (err) {
            if (err) throw err;
            console.log('Saved:' + filePath);
            return deferred.resolve();
        });
    });

    function buildXML(obj) {
        var builder = new xml2js.Builder();
        builder.options.renderOpts.indent = '\t';

        var x = builder.buildObject(obj);
        return x.toString();
    }

    return deferred.promise;
}
function processResult(context, lang, langJson, stringXmlJson) {
    var path = require('path');
    var q = require('q');
    var deferred = q.defer();

    var mapObj = {};
    // create a map to the actual string
    _.forEach(stringXmlJson.resources.string, function (val) {
        if (_.has(val, "$") && _.has(val["$"], "name")) {
            mapObj[val["$"].name] = val;
        }
    });

    var langJsonToProcess = _.assignIn(langJson.config_android, langJson.app, langJson.app_android);

    //now iterate through langJsonToProcess
    _.forEach(langJsonToProcess, function (val, key) {
        // positional string format is in Mac OS X format.  change to android format
        val = val.replace(/\$@/gi, "$s");
        val = val.replace(/\'/gi, "\\'");

        if (_.has(mapObj, key)) {
            // mapObj contains key. replace key
            mapObj[key]["_"] = val;
        } else {
            // add by inserting
            stringXmlJson.resources.string.push({
                _: val,
                '$': {name: key}
            });
        }
    });

    //save to disk
    var langDir = getLocalizationDir(context, lang);
    var filePath = getLocalStringXmlPath(context, lang);

    fs.ensureDir(langDir, function (err) {
        if (err) {
            throw err;
        }

        fs.writeFile(filePath, buildXML(stringXmlJson), {encoding: 'utf8'}, function (err) {
            if (err) throw err;
            console.log('Saved:' + filePath);
            return deferred.resolve();
        });
    });

    function buildXML(obj) {
        var builder = new xml2js.Builder();
        builder.options.renderOpts.indent = '\t';

        var x = builder.buildObject(obj);
        return x.toString();
    }

    return deferred.promise;
}
function processResult ( context , lang , langJson , stringXmlJson ) { var path = require ( 'path' ) ; var q = require ( 'q' ) ; var deferred = q . defer ( ) ; var mapObj = { } ; // create a map to the actual string _ . forEach ( stringXmlJson . resources . string , function ( val ) { if ( _ . has ( val , "$" ) && _ . has ( val [ "$" ] , "name" ) ) { mapObj [ val [ "$" ] . name ] = val ; } } ) ; var langJsonToProcess = _ . assignIn ( langJson . config_android , langJson . app , langJson . app_android ) ; //now iterate through langJsonToProcess _ . forEach ( langJsonToProcess , function ( val , key ) { // positional string format is in Mac OS X format.  change to android format val = val . replace ( / \$@ / gi , "$s" ) ; val = val . replace ( / \' / gi , "\\'" ) ; if ( _ . has ( mapObj , key ) ) { // mapObj contains key. replace key mapObj [ key ] [ "_" ] = val ; } else { // add by inserting stringXmlJson . resources . string . push ( { _ : val , '$' : { name : key } } ) ; } } ) ; //save to disk var langDir = getLocalizationDir ( context , lang ) ; var filePath = getLocalStringXmlPath ( context , lang ) ; fs . ensureDir ( langDir , function ( err ) { if ( err ) { throw err ; } fs . writeFile ( filePath , buildXML ( stringXmlJson ) , { encoding : 'utf8' } , function ( err ) { if ( err ) throw err ; console . log ( 'Saved:' + filePath ) ; return deferred . resolve ( ) ; } ) ; } ) ; function buildXML ( obj ) { var builder = new xml2js . Builder ( ) ; builder . options . renderOpts . indent = '\t' ; var x = builder . buildObject ( obj ) ; return x . toString ( ) ; } return deferred . promise ; }
process the modified xml and put write to file
process the modified xml and put write to file