-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
1 parent
0f7717e
commit 265669d
Showing
4 changed files
with
155 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.