diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2018-03-21 01:59:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 01:59:42 +0800 |
commit | a3c1a925132abb8232e911ac028ac2aab1669d45 (patch) | |
tree | 698ad3a903bd7124605e54c28829ded850498502 /development | |
parent | 706a94318920c9c425a6881eded3b738446ebb39 (diff) | |
parent | 03587c96d86b439ef924bde12cf0ce5012983f38 (diff) | |
download | tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar.gz tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar.bz2 tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar.lz tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar.xz tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.tar.zst tangerine-wallet-browser-a3c1a925132abb8232e911ac028ac2aab1669d45.zip |
Merge pull request #3612 from hermanjunge/locale-verification
Add script to verify locale strings
Diffstat (limited to 'development')
-rw-r--r-- | development/verify-locale-strings.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/development/verify-locale-strings.js b/development/verify-locale-strings.js new file mode 100644 index 000000000..b8fe5a7dc --- /dev/null +++ b/development/verify-locale-strings.js @@ -0,0 +1,96 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Locale verification script +// +// usage: +// +// node app/scripts/verify-locale-strings.js <locale> +// +// will check the given locale against the strings in english +// +//////////////////////////////////////////////////////////////////////////////// + +var fs = require('fs') +var path = require('path') + +console.log('Locale Verification') + +var locale = process.argv[2] +if (!locale || locale == '') { + console.log('Must enter a locale as argument. exitting') + process.exit(1) +} + +console.log("verifying for locale " + locale) + +localeFilePath = path.join(process.cwd(), 'app', '_locales', locale, 'messages.json') +try { + localeObj = JSON.parse(fs.readFileSync(localeFilePath, 'utf8')); +} catch (e) { + if(e.code == 'ENOENT') { + console.log('Locale file not found') + } else { + console.log('Error opening your locale file: ', e) + } + process.exit(1) +} + +englishFilePath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json') +try { + englishObj = JSON.parse(fs.readFileSync(englishFilePath, 'utf8')); +} catch (e) { + if(e.code == 'ENOENT') { + console.log("English File not found") + } else { + console.log("Error opening english locale file: ", e) + } + process.exit(1) +} + +console.log('\tverifying whether all your locale strings are contained in the english one') + +var counter = 0 +var foundErrorA = false +var notFound = []; +Object.keys(localeObj).forEach(function(key){ + if (!englishObj[key]) { + foundErrorA = true + notFound.push(key) + } + counter++ +}) + +if (foundErrorA) { + console.log('\nThe following string(s) is(are) not found in the english locale:') + notFound.forEach(function(key) { + console.log(key) + }) +} else { + console.log('\tall ' + counter +' strings declared in your locale were found in the english one') +} + +console.log('\n\tverifying whether your locale contains all english strings') + +var counter = 0 +var foundErrorB = false +var notFound = []; +Object.keys(englishObj).forEach(function(key){ + if (!localeObj[key]) { + foundErrorB = true + notFound.push(key) + } + counter++ +}) + +if (foundErrorB) { + console.log('\nThe following string(s) is(are) not found in the your locale:') + notFound.forEach(function(key) { + console.log(key) + }) +} else { + console.log('\tall ' + counter +' english strings were found in your locale!') +} + +if (!foundErrorA && !foundErrorB) { + console.log('You are good to go') +}
\ No newline at end of file |