Permalink
Browse files

check-locales: include full missing translation

  • Loading branch information...
mmckegg committed Oct 28, 2017
1 parent 82d1bb1 commit 148b12cf2f02a4589bf31b606578d7ffd08e7028
Showing with 10 additions and 7 deletions.
  1. +10 −7 scripts/check-locales.js
View
@@ -1,13 +1,14 @@
// adapted from https://gist.github.com/gmarcos87/565d57747b30e1755046002137228562
const genericFile = require('../locales/en.json')
var baseTranslation = 'en'
const genericFile = require('../locales/' + baseTranslation + '.json')
const colors = require('colors')
const Path = require('path')
// Load all translation in locales folder
let translations = {}
require('fs').readdirSync(Path.join(__dirname, '..', 'locales')).forEach((file) => {
if (file.match(/\.json$/) !== null) {
if (file.match(/\.json$/) !== null && baseTranslation + '.json' !== file) {
let name = file.replace('.json', '')
translations[name] = require('../locales/' + file)
}
@@ -19,22 +20,24 @@ const missing = (master, slave) => {
}
console.log(colors.bold.underline('Translations differences'))
console.log('Comparing with', colors.yellow(baseTranslation))
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'))
console.log()
console.log(colors.bold('./locales/' + lang + '.json'))
if (translationsMissing.length) {
console.log(colors.green(' +++ missing translations'))
console.log(colors.green('+++ missing translations'))
console.log(
translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ""').join(',\n')
translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ' + JSON.stringify(genericFile[x])).join(',\n')
)
}
if (translationsSurplus.length) {
console.log(colors.red(' --- surplus translations'))
translationsSurplus.map(x => console.log(colors.red(' ' + JSON.stringify(x))))
console.log(colors.red('--- surplus translations'))
translationsSurplus.map(x => console.log(colors.red(' ' + JSON.stringify(x))))
}
})

0 comments on commit 148b12c

Please sign in to comment.