Skip to content

Instantly share code, notes, and snippets.

@Grsmto
Created December 8, 2017 13:09
Show Gist options
  • Save Grsmto/22c9c7ddb6b69977434921cb0bd44660 to your computer and use it in GitHub Desktop.
Save Grsmto/22c9c7ddb6b69977434921cb0bd44660 to your computer and use it in GitHub Desktop.
Node.js script to prepare files for translation on Prismic.io
var fs = require('fs');
var dirPath = './imports';
var lang = 'de-de';
var files = fs.readdirSync(dirPath).filter(item => !(/(^|\/)\.[^\/\.]/g).test(item));
files.forEach(function(file) {
fs.readFile(dirPath + '/' + file, function(error, data) {
if (error) {
console.log(error);
return;
}
var obj = JSON.parse(data);
fs.rename(dirPath + '/' + file, './imports/translate_' + obj.grouplang + '_' + lang + '.json', function(err) {
if (err) console.log('ERROR: ' + err);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment