Skip to content

Instantly share code, notes, and snippets.

@jamlfy
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save jamlfy/0dc48b3187aaf73a15e8 to your computer and use it in GitHub Desktop.

Select an option

Save jamlfy/0dc48b3187aaf73a15e8 to your computer and use it in GitHub Desktop.
Creator in i18n for NativeLang
#!/bin/env node
const fs = require('fs');
const path = require('path');
const childProcess = require('child_process');
const async = require('async');
const RUNTIME = {
android : function (dir, values, call) {
var master = [];
for (var i = values.length - 1; i >= 0; i--) {
master.push({
'in' : path.join(dir, 'res', 'values' + ( values[i] === 'en' ? '' : '-' + values[i] ) ),
'out' : path.join(process.pwd, 'i18n', values[i], '*' )
});
}
async.map(master, function (item, next) {
fs.exists(item.in, function (is) {
if(!is) fs.mkdirSync(item.in);
childProcess.exec('cp -R -F ' + item.out + ' ' + item.in, function (err, o, strerror) {
next(err || strerror);
});
});
}, callback);
},
ios : function (dir, values, call) {
}
};
async.parallel({
platform : function (callback) {
fs.readdir(path.join(process.pwd, 'platform' ), callback);
},
i18n : function (callback) {
fs.readdir(path.join(process.pwd, 'i18n' ), callback);
}
}, function (err, data) {
if(err) throw err;
async.map(data.platform, function (name, next) {
var dirPlatform = path.join(process.pwd, 'platform', name);
RUNTIME[name](dirPlatform, data.i18n, next);
}, function(err){
if(err) conosole.log(err);
process.kill();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment