Commit 148b12cf2f02a4589bf31b606578d7ffd08e7028
check-locales: include full missing translation
Matt McKegg committed on 10/28/2017, 11:41:21 AMParent: 82d1bb1396515575dc15b40dff81c0bb7ecf07b8
Files changed
scripts/check-locales.js | changed |
scripts/check-locales.js | ||
---|---|---|
@@ -1,14 +1,15 @@ | ||
1 | 1 | // adapted from https://gist.github.com/gmarcos87/565d57747b30e1755046002137228562 |
2 | 2 | |
3 | -const genericFile = require('../locales/en.json') | |
3 | +var baseTranslation = 'en' | |
4 | +const genericFile = require('../locales/' + baseTranslation + '.json') | |
4 | 5 | const colors = require('colors') |
5 | 6 | const Path = require('path') |
6 | 7 | |
7 | 8 | // Load all translation in locales folder |
8 | 9 | let translations = {} |
9 | 10 | require('fs').readdirSync(Path.join(__dirname, '..', 'locales')).forEach((file) => { |
10 | - if (file.match(/\.json$/) !== null) { | |
11 | + if (file.match(/\.json$/) !== null && baseTranslation + '.json' !== file) { | |
11 | 12 | let name = file.replace('.json', '') |
12 | 13 | translations[name] = require('../locales/' + file) |
13 | 14 | } |
14 | 15 | }) |
@@ -18,23 +19,25 @@ | ||
18 | 19 | return Object.keys(master).filter(key => slaveKeys.indexOf(key) === -1) |
19 | 20 | } |
20 | 21 | |
21 | 22 | console.log(colors.bold.underline('Translations differences')) |
23 | +console.log('Comparing with', colors.yellow(baseTranslation)) | |
22 | 24 | |
23 | 25 | Object.keys(translations).forEach((lang) => { |
24 | 26 | const translationsMissing = missing(genericFile, translations[lang]) |
25 | 27 | const translationsSurplus = missing(translations[lang], genericFile) |
26 | 28 | |
27 | 29 | // Print Output |
28 | - console.log(colors.bold(' ./locales/' + lang + '.json')) | |
30 | + console.log() | |
31 | + console.log(colors.bold('./locales/' + lang + '.json')) | |
29 | 32 | |
30 | 33 | if (translationsMissing.length) { |
31 | - console.log(colors.green(' +++ missing translations')) | |
34 | + console.log(colors.green('+++ missing translations')) | |
32 | 35 | console.log( |
33 | - translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ""').join(',\n') | |
36 | + translationsMissing.map(x => ' ' + JSON.stringify(x) + ': ' + JSON.stringify(genericFile[x])).join(',\n') | |
34 | 37 | ) |
35 | 38 | } |
36 | 39 | 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)))) | |
39 | 42 | } |
40 | 43 | }) |
Built with git-ssb-web