git ssb

10+

Matt McKegg / patchwork



Commit 148b12cf2f02a4589bf31b606578d7ffd08e7028

check-locales: include full missing translation

Matt McKegg committed on 10/28/2017, 11:41:21 AM
Parent: 82d1bb1396515575dc15b40dff81c0bb7ecf07b8

Files changed

scripts/check-locales.jschanged
scripts/check-locales.jsView
@@ -1,14 +1,15 @@
11 // adapted from https://gist.github.com/gmarcos87/565d57747b30e1755046002137228562
22
3-const genericFile = require('../locales/en.json')
3+var baseTranslation = 'en'
4+const genericFile = require('../locales/' + baseTranslation + '.json')
45 const colors = require('colors')
56 const Path = require('path')
67
78 // Load all translation in locales folder
89 let translations = {}
910 require('fs').readdirSync(Path.join(__dirname, '..', 'locales')).forEach((file) => {
10- if (file.match(/\.json$/) !== null) {
11+ if (file.match(/\.json$/) !== null && baseTranslation + '.json' !== file) {
1112 let name = file.replace('.json', '')
1213 translations[name] = require('../locales/' + file)
1314 }
1415 })
@@ -18,23 +19,25 @@
1819 return Object.keys(master).filter(key => slaveKeys.indexOf(key) === -1)
1920 }
2021
2122 console.log(colors.bold.underline('Translations differences'))
23+console.log('Comparing with', colors.yellow(baseTranslation))
2224
2325 Object.keys(translations).forEach((lang) => {
2426 const translationsMissing = missing(genericFile, translations[lang])
2527 const translationsSurplus = missing(translations[lang], genericFile)
2628
2729 // Print Output
28- console.log(colors.bold(' ./locales/' + lang + '.json'))
30+ console.log()
31+ console.log(colors.bold('./locales/' + lang + '.json'))
2932
3033 if (translationsMissing.length) {
31- console.log(colors.green(' +++ missing translations'))
34+ console.log(colors.green('+++ missing translations'))
3235 console.log(
33- translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ""').join(',\n')
36+ translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ' + JSON.stringify(genericFile[x])).join(',\n')
3437 )
3538 }
3639 if (translationsSurplus.length) {
37- console.log(colors.red(' --- surplus translations'))
38- translationsSurplus.map(x => console.log(colors.red(' ' + JSON.stringify(x))))
40+ console.log(colors.red('--- surplus translations'))
41+ translationsSurplus.map(x => console.log(colors.red(' ' + JSON.stringify(x))))
3942 }
4043 })

Built with git-ssb-web