Created
December 8, 2017 13:09
-
-
Save Grsmto/22c9c7ddb6b69977434921cb0bd44660 to your computer and use it in GitHub Desktop.
Node.js script to prepare files for translation on Prismic.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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