diff --git a/package.json b/package.json index b77ab13607..ded4964071 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "@types/validator": "~13.0.0", "@typescript-eslint/eslint-plugin": "~2.30.0", "@typescript-eslint/parser": "~2.30.0", + "chalk": "^4.0.0", "commitizen": "~4.0.3", "commitlint-config-cz": "~0.13.0", "cross-env": "~7.0.0", diff --git a/scripts/.eslintrc.js b/scripts/.eslintrc.js new file mode 100644 index 0000000000..c6ef8183ad --- /dev/null +++ b/scripts/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + extends: '../.eslintrc.js', + rules: { + "import/no-extraneous-dependencies": ["error", {"devDependencies": true}] + } +} diff --git a/scripts/checkMissingTranslations.ts b/scripts/checkMissingTranslations.ts index f9f793ff08..61ff037372 100644 --- a/scripts/checkMissingTranslations.ts +++ b/scripts/checkMissingTranslations.ts @@ -1,6 +1,11 @@ import { Resource, ResourceKey } from 'i18next' +import chalk from 'chalk' import i18n from '../src/i18n' +const error = chalk.bold.red +const warning = chalk.keyword('orange') +const success = chalk.keyword('green') + const checkRecursiveTranslation = ( comparingLanguage: string, searchingPath: string[], @@ -10,9 +15,11 @@ const checkRecursiveTranslation = ( if (typeof defaultLanguageObject === 'string' || typeof comparingLanguageObject === 'string') { if (typeof defaultLanguageObject === 'object') { console.log( - `πŸ“™ Found a string for path ${searchingPath.join( - '-->', - )} and language ${comparingLanguage} while is and object for the default language`, + warning( + `Found a string for path ${searchingPath.join( + '-->', + )} and language ${comparingLanguage} while is and object for the default language`, + ), ) } return @@ -24,10 +31,12 @@ const checkRecursiveTranslation = ( } defaultKeys.forEach((key) => { if (!comparingLanguageObject[key]) { - console.log( - `πŸ“™ The key ${key} is not present for path ${searchingPath.join( - '-->', - )} and language ${comparingLanguage}`, + console.warn( + warning( + `The key ${key} is not present for path ${searchingPath.join( + '-->', + )} and language ${comparingLanguage}`, + ), ) } else { checkRecursiveTranslation( @@ -45,11 +54,13 @@ const run = () => { const languages = Object.keys(resources) const defaultLanguage = 'en' console.log( - '🏁 Start finding translation problem comparing all languages with the default one (English)', + success( + '🏁 Start finding translation problem comparing all languages with the default one (English)', + ), ) console.log('') if (!resources[defaultLanguage]) { - console.log('πŸ“• We have a big problem.... the english language is not found!') + console.log(error('We have a big problem.... the english language is not found!')) process.exit(1) } @@ -57,7 +68,7 @@ const run = () => { if (language === defaultLanguage) { return } - console.log(`🀞Checking ${language}`) + console.log(success(`Checking ${language}`)) console.log('') checkRecursiveTranslation(language, [language], resources[defaultLanguage], resources[language]) console.log('')