Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const genericFile = require('./locales/en.json')
- const colors = require('colors')
- // Load all translation in locales folder
- let translations = {}
- require('fs').readdirSync('./locales/').forEach((file) => {
- if (file.match(/\.json$/) !== null) {
- let name = file.replace('.json', '')
- translations[name] = require('./locales/' + file)
- }
- });
- const missing = (master, slave) => {
- const slaveKeys = Object.keys(slave)
- return Object.keys(master).filter(key => slaveKeys.indexOf(key)=== -1)
- };
- const init = () => {
- console.log(colors.bold.underline('Translations differences'))
- Object.keys(translations)
- .forEach((lang) => {
- const translationsMissing = missing(genericFile,translations[lang])
- const translationsSurplus = missing(translations[lang],genericFile)
- //Print Output
- console.log(colors.bold(' ./locales/' + lang + '.json'))
- translationsMissing.map( x => console.log(colors.green(' +++ '+ x)))
- translationsSurplus.map( x => console.log(colors.red(' --- '+ x)))
- });
- };
- init();
Add Comment
Please, Sign In to add comment