Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[IMPROVE] German translations (#12471)
* Script for determining a diff between language files

* Correct and sort german language files

* Manually checked the lingo-hub additions
as per 3603b37

* Removed duplicate translation keys
  • Loading branch information
mrsimpson authored and sampaiodiego committed Oct 30, 2018
1 parent 0f7717e commit 265669d
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 80 deletions.
38 changes: 38 additions & 0 deletions .scripts/translationDiff.js
@@ -0,0 +1,38 @@
#!/usr/bin/env node

const path = require('path');
const fs = require('fs');
const util = require('util');

// Convert fs.readFile into Promise version of same
const readFile = util.promisify(fs.readFile);

const translationDir = path.resolve(__dirname, '../packages/rocketchat-i18n/i18n/');

async function translationDiff(source, target) {
console.debug('loading translations from', translationDir);

function diffKeys(a, b) {
const diff = {};
Object.keys(a).forEach((key) => {
if (!b[key]) {
diff[key] = a[key];
}
});

return diff;
}

const sourceTranslations = JSON.parse(await readFile(`${ translationDir }/${ source }.i18n.json`, 'utf8'));
const targetTranslations = JSON.parse(await readFile(`${ translationDir }/${ target }.i18n.json`, 'utf8'));

return diffKeys(sourceTranslations, targetTranslations);
}

console.log('Note: You can set the source and target language of the comparison with env-variables SOURCE/TARGET_LANGUAGE');
const sourceLang = process.env.SOURCE_LANGUAGE || 'en';
const targetLang = process.env.TARGET_LANGUAGE || 'de';
translationDiff(sourceLang, targetLang).then((diff) => {
console.log('Diff between', sourceLang, 'and', targetLang);
console.log(JSON.stringify(diff, '', 2));
});
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -73,6 +73,7 @@
"testunit-watch": "mocha --watch --opts ./mocha.opts \"`node -e \"console.log(require('./package.json').mocha.tests.join(' '))\"`\"",
"coverage": "nyc -r html mocha --opts ./mocha.opts \"`node -e \"console.log(require('./package.json').mocha.tests.join(' '))\"`\"",
"testunit": "mocha --opts ./mocha.opts \"`node -e \"console.log(require('./package.json').mocha.tests.join(' '))\"`\"",
"translation-diff": "node .scripts/translationDiff.js",
"version": "node .scripts/version.js",
"set-version": "node .scripts/set-version.js",
"release": "meteor npm run set-version --silent",
Expand Down

0 comments on commit 265669d

Please sign in to comment.