From 8421cf1954fb017dc5311368cc3ee335b34ca446 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 19:59:45 -0700 Subject: i18n - fix casing for key 'downloadStateLogs' --- app/_locales/de/messages.json | 2 +- app/_locales/es/messages.json | 2 +- app/_locales/hn/messages.json | 2 +- app/_locales/nl/messages.json | 2 +- app/_locales/ru/messages.json | 2 +- app/_locales/sl/messages.json | 2 +- app/_locales/th/messages.json | 2 +- app/_locales/zh_TW/messages.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/_locales/de/messages.json b/app/_locales/de/messages.json index 0bdce516c..822991512 100644 --- a/app/_locales/de/messages.json +++ b/app/_locales/de/messages.json @@ -217,7 +217,7 @@ "done": { "message": "Fertig" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Statelogs herunterladen" }, "dropped": { diff --git a/app/_locales/es/messages.json b/app/_locales/es/messages.json index fa28b09da..f287674f1 100644 --- a/app/_locales/es/messages.json +++ b/app/_locales/es/messages.json @@ -247,7 +247,7 @@ "done": { "message": "Completo" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Descargar logs de estado" }, "dropped": { diff --git a/app/_locales/hn/messages.json b/app/_locales/hn/messages.json index 3703faa13..323f4b4b3 100644 --- a/app/_locales/hn/messages.json +++ b/app/_locales/hn/messages.json @@ -223,7 +223,7 @@ "done": { "message": "संपन्न" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "राज्य लॉग डाउनलोड करें" }, "edit": { diff --git a/app/_locales/nl/messages.json b/app/_locales/nl/messages.json index aacb81fee..c2f955123 100644 --- a/app/_locales/nl/messages.json +++ b/app/_locales/nl/messages.json @@ -223,7 +223,7 @@ "done": { "message": "Gedaan" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Staatslogboeken downloaden" }, "edit": { diff --git a/app/_locales/ru/messages.json b/app/_locales/ru/messages.json index e3a1935f5..01debddc2 100644 --- a/app/_locales/ru/messages.json +++ b/app/_locales/ru/messages.json @@ -223,7 +223,7 @@ "done": { "message": "Готово" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Загрузить логи статус" }, "edit": { diff --git a/app/_locales/sl/messages.json b/app/_locales/sl/messages.json index 0532f11b2..b089f3476 100644 --- a/app/_locales/sl/messages.json +++ b/app/_locales/sl/messages.json @@ -223,7 +223,7 @@ "done": { "message": "Končano" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "Prenesi state dnevnike" }, "edit": { diff --git a/app/_locales/th/messages.json b/app/_locales/th/messages.json index 887714f3f..3d7dec226 100644 --- a/app/_locales/th/messages.json +++ b/app/_locales/th/messages.json @@ -223,7 +223,7 @@ "done": { "message": "เสร็จสิ้น" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "ดาวน์โหลดล็อกสถานะ" }, "edit": { diff --git a/app/_locales/zh_TW/messages.json b/app/_locales/zh_TW/messages.json index e39793430..9aaee0e16 100644 --- a/app/_locales/zh_TW/messages.json +++ b/app/_locales/zh_TW/messages.json @@ -235,7 +235,7 @@ "done": { "message": "完成" }, - "downloadStatelogs": { + "downloadStateLogs": { "message": "下載狀態紀錄" }, "dropped": { -- cgit From 3e7d7205b8b841f619a77da6c2d28da88fef66a7 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 20:09:15 -0700 Subject: i18n - cleanup verify locales util --- development/verify-locale-strings.js | 146 +++++++++++++++++++---------------- 1 file changed, 80 insertions(+), 66 deletions(-) diff --git a/development/verify-locale-strings.js b/development/verify-locale-strings.js index b8fe5a7dc..c0214d672 100644 --- a/development/verify-locale-strings.js +++ b/development/verify-locale-strings.js @@ -10,87 +10,101 @@ // //////////////////////////////////////////////////////////////////////////////// -var fs = require('fs') -var path = require('path') +const fs = require('fs') +const path = require('path') +const locales = require('../app/_locales/index.json') console.log('Locale Verification') -var locale = process.argv[2] -if (!locale || locale == '') { - console.log('Must enter a locale as argument. exitting') - process.exit(1) +const specifiedLocale = process.argv[2] +if (specifiedLocale) { + console.log(`Verifying selected locale "${specifiedLocale}":\n\n`) + const locale = locales.find(locale => locale.code === specifiedLocale) + verifyLocale({ locale }) +} else { + console.log('Verifying all locales:\n\n') + locales.forEach(locale => { + verifyLocale({ locale }) + console.log('\n') + }) } -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) + +function verifyLocale({ locale }) { + const localeCode = locale.code + const localeName = locale.name + console.log(`Status of "${localeName}" (${localeCode})`) + + try { + const localeFilePath = path.join(process.cwd(), 'app', '_locales', localeCode, 'messages.json') + 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 ("${localeCode}") file: `, e) + } + process.exit(1) } - 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) + try { + const englishFilePath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json') + 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) } - process.exit(1) -} -console.log('\tverifying whether all your locale strings are contained in the english one') + // console.log(' verifying whether all your locale ("${localeCode}") 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++ + }) -var counter = 0 -var foundErrorA = false -var notFound = []; -Object.keys(localeObj).forEach(function(key){ - if (!englishObj[key]) { - foundErrorA = true - notFound.push(key) + if (foundErrorA) { + console.log('\nMissing from english locale:') + notFound.forEach(function(key) { + console.log(` - [ ] ${key}`) + }) + } else { + // console.log(` all ${counter} strings declared in your locale ("${localeCode}") were found in the english one`) } - 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 verifying whether your locale ("${localeCode}") contains all english strings') -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++ + }) -var counter = 0 -var foundErrorB = false -var notFound = []; -Object.keys(englishObj).forEach(function(key){ - if (!localeObj[key]) { - foundErrorB = true - notFound.push(key) + if (foundErrorB) { + console.log(`\nMissing from "${localeCode}":`) + notFound.forEach(function(key) { + console.log(` - [ ] ${key}`) + }) + } else { + // console.log(` all ${counter} english strings were found in your locale ("${localeCode}")!`) } - 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') + } } - -if (!foundErrorA && !foundErrorB) { - console.log('You are good to go') -} \ No newline at end of file -- cgit From 812a06ffcd9cea39453e8a59563bf1d12e17c065 Mon Sep 17 00:00:00 2001 From: kumavis Date: Tue, 27 Mar 2018 20:29:29 -0700 Subject: i18n - further improve locale verifier --- development/verify-locale-strings.js | 69 +++++++++++++++--------------------- 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/development/verify-locale-strings.js b/development/verify-locale-strings.js index c0214d672..8dc0a30f1 100644 --- a/development/verify-locale-strings.js +++ b/development/verify-locale-strings.js @@ -12,33 +12,32 @@ const fs = require('fs') const path = require('path') -const locales = require('../app/_locales/index.json') +const localeIndex = require('../app/_locales/index.json') console.log('Locale Verification') const specifiedLocale = process.argv[2] if (specifiedLocale) { console.log(`Verifying selected locale "${specifiedLocale}":\n\n`) - const locale = locales.find(locale => locale.code === specifiedLocale) - verifyLocale({ locale }) + const locale = localeIndex.find(localeMeta => localeMeta.code === specifiedLocale) + verifyLocale({ localeMeta }) } else { console.log('Verifying all locales:\n\n') - locales.forEach(locale => { - verifyLocale({ locale }) + localeIndex.forEach(localeMeta => { + verifyLocale({ localeMeta }) console.log('\n') }) } -function verifyLocale({ locale }) { - const localeCode = locale.code - const localeName = locale.name - console.log(`Status of "${localeName}" (${localeCode})`) +function verifyLocale({ localeMeta }) { + const localeCode = localeMeta.code + const localeName = localeMeta.name try { const localeFilePath = path.join(process.cwd(), 'app', '_locales', localeCode, 'messages.json') - localeObj = JSON.parse(fs.readFileSync(localeFilePath, 'utf8')); + targetLocale = JSON.parse(fs.readFileSync(localeFilePath, 'utf8')); } catch (e) { if (e.code == 'ENOENT') { console.log('Locale file not found') @@ -50,7 +49,7 @@ function verifyLocale({ locale }) { try { const englishFilePath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json') - englishObj = JSON.parse(fs.readFileSync(englishFilePath, 'utf8')); + englishLocale = JSON.parse(fs.readFileSync(englishFilePath, 'utf8')); } catch (e) { if(e.code == 'ENOENT') { console.log('English File not found') @@ -61,50 +60,38 @@ function verifyLocale({ locale }) { } // console.log(' verifying whether all your locale ("${localeCode}") strings are contained in the english one') + const extraItems = compareLocalesForMissingItems({ base: targetLocale, subject: englishLocale }) + // console.log('\n verifying whether your locale ("${localeCode}") contains all english strings') + const missingItems = compareLocalesForMissingItems({ base: englishLocale, subject: targetLocale }) - var counter = 0 - var foundErrorA = false - var notFound = []; - Object.keys(localeObj).forEach(function(key){ - if (!englishObj[key]) { - foundErrorA = true - notFound.push(key) - } - counter++ - }) + const englishEntryCount = Object.keys(englishLocale).length + const coveragePercent = 100 * (englishEntryCount - missingItems.length) / englishEntryCount - if (foundErrorA) { + console.log(`Status of **${localeName} (${localeCode})** ${coveragePercent.toFixed(2)}% coverage:`) + + if (extraItems.length) { console.log('\nMissing from english locale:') - notFound.forEach(function(key) { + extraItems.forEach(function(key) { console.log(` - [ ] ${key}`) }) } else { // console.log(` all ${counter} strings declared in your locale ("${localeCode}") were found in the english one`) } - // console.log('\n verifying whether your locale ("${localeCode}") 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(`\nMissing from "${localeCode}":`) - notFound.forEach(function(key) { + if (missingItems.length) { + console.log(`\nMissing:`) + missingItems.forEach(function(key) { console.log(` - [ ] ${key}`) }) } else { // console.log(` all ${counter} english strings were found in your locale ("${localeCode}")!`) } - if (!foundErrorA && !foundErrorB) { - console.log('You are good to go') + if (!extraItems.length && !missingItems.length) { + console.log('Full coverage : )') } } + +function compareLocalesForMissingItems({ base, subject }) { + return Object.keys(base).filter((key) => !subject[key]) +} -- cgit From 0d591d8da264dd0056442a5033a1112013cba3e0 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Apr 2018 11:10:43 -0700 Subject: Update translating-guide.md --- docs/translating-guide.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/translating-guide.md b/docs/translating-guide.md index ae2dfecd3..8b2bc1785 100644 --- a/docs/translating-guide.md +++ b/docs/translating-guide.md @@ -6,9 +6,12 @@ The MetaMask browser extension supports new translations added in the form of ne ## Adding a new Language -Each supported language is represented by a folder in `app/_locales` whose name is that language's subtag ([look up a language subtag using this tool](https://r12a.github.io/app-subtags/)). +- Each supported language is represented by a folder in `app/_locales` whose name is that language's subtag (example: `app/_locales/es/`). (look up a language subtag using the [r12a "Find" tool](https://r12a.github.io/app-subtags/) or this [wikipedia list](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)). +- Inside that folder there should be a `messages.json`. +- An easy way to start your translation is to first **make a copy** of `app/_locales/en/messages.json` (the english translation), and then **translate the `message` key** for each in-app message. +- **The `description` key** is just to add context for what the translation is about, it **does not need to be translated**. +- Add the language to the [locales index](https://github.com/MetaMask/metamask-extension/blob/master/app/_locales/index.json) `app/_locales/index.json` -Inside that folder there should be a `messages.json` file that follows the specified format. An easy way to start your translation is to first duplicate `app/_locales/en/messages.json` (the english translation), and then update the `message` key for each in-app message. That's it! When MetaMask is loaded on a computer with that language set as the system language, they will see your translation instead of the default one. @@ -20,7 +23,7 @@ To automatically see if you are missing any phrases to translate, we have a scri node development/verify-locale-strings.js $YOUR_LOCALE ``` -Where `$YOUR_LOCALE` is your [locale string](https://r12a.github.io/app-subtags/), i.e. the name of your language folder. +Where `$YOUR_LOCALE` is your locale string (example: `es`), i.e. the name of your language folder. To verify that your translation works in the app, you will need to [build a local copy](https://github.com/MetaMask/metamask-extension#building-locally) of MetaMask. You will need to change your browser language, your operating system language, and restart your browser (sorry it's so much work!). -- cgit From 04d85fd79e378dc4830719ce3b742feb9d5de6a3 Mon Sep 17 00:00:00 2001 From: kumavis Date: Mon, 2 Apr 2018 11:50:22 -0700 Subject: deps - bump package-lock.json --- package-lock.json | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/package-lock.json b/package-lock.json index 18d49971e..fe47f8cf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7148,12 +7148,6 @@ "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" }, - "fork-stream": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/fork-stream/-/fork-stream-0.0.4.tgz", - "integrity": "sha1-24Sfznf2cIpfjzhq5TOgkHtUrnA=", - "dev": true - }, "form-data": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", @@ -8683,17 +8677,6 @@ "gulp-util": "3.0.8" } }, - "gulp-if": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/gulp-if/-/gulp-if-2.0.2.tgz", - "integrity": "sha1-pJe351cwBQQcqivIt92jyARE1ik=", - "dev": true, - "requires": { - "gulp-match": "1.0.3", - "ternary-stream": "2.0.1", - "through2": "2.0.3" - } - }, "gulp-json-editor": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/gulp-json-editor/-/gulp-json-editor-2.2.1.tgz", @@ -8845,15 +8828,6 @@ } } }, - "gulp-match": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/gulp-match/-/gulp-match-1.0.3.tgz", - "integrity": "sha1-kcfA1/Kb7NZgbVfYCn+Hdqh6uo4=", - "dev": true, - "requires": { - "minimatch": "3.0.4" - } - }, "gulp-replace": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/gulp-replace/-/gulp-replace-0.6.1.tgz", @@ -13247,15 +13221,6 @@ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" }, - "merge-stream": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", - "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", - "dev": true, - "requires": { - "readable-stream": "2.3.3" - } - }, "merkle-patricia-tree": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/merkle-patricia-tree/-/merkle-patricia-tree-2.3.0.tgz", @@ -20753,18 +20718,6 @@ "inherits": "2.0.3" } }, - "ternary-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ternary-stream/-/ternary-stream-2.0.1.tgz", - "integrity": "sha1-Bk5Im0tb9gumpre8fy9cJ07Pgmk=", - "dev": true, - "requires": { - "duplexify": "3.5.1", - "fork-stream": "0.0.4", - "merge-stream": "1.0.1", - "through2": "2.0.3" - } - }, "testem": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/testem/-/testem-2.0.0.tgz", -- cgit