diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9e87e0eb0a3..ef34990a930 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -41,6 +41,7 @@ jobs: npm run test:lib npm run test:styles npm run test:schematics + npm run test:i18n env: NODE_OPTIONS: --max_old_space_size=4096 - name: Build i18n & validate output diff --git a/package.json b/package.json index 027dcdee0fb..465cbcdc777 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "test:lib:watch": "ng test igniteui-angular --karma-config=./projects/igniteui-angular/karma.watch.conf.js", "test:schematics": "ts-node --project projects/igniteui-angular/migrations/tsconfig.json ./node_modules/jasmine/bin/jasmine.js ./projects/igniteui-angular/migrations/**/*.spec.ts ./projects/igniteui-angular/schematics/**/*.spec.ts", "test:styles": "ts-node --skip-project ./node_modules/jasmine/bin/jasmine.js ./projects/igniteui-angular/src/lib/core/styles/spec/tests.ts", + "test:i18n": "ts-node --skip-project ./projects/igniteui-angular/src/lib/core/i18n/tests/tests.ts", "build:lib": "ng build igniteui-angular --configuration production && gulp buildStyle", "build:style": "gulp buildStyle", "build:migration": "gulp copyMigrations && tsc --listEmittedFiles --project ./projects/igniteui-angular/migrations/tsconfig.json", diff --git a/projects/igniteui-angular/src/lib/core/i18n/tests/tests.ts b/projects/igniteui-angular/src/lib/core/i18n/tests/tests.ts new file mode 100644 index 00000000000..761a09df849 --- /dev/null +++ b/projects/igniteui-angular/src/lib/core/i18n/tests/tests.ts @@ -0,0 +1,31 @@ +import * as fs from 'fs'; +import * as path from 'path'; + +const i18nProductPath = path.join(__dirname, '../'); +const i18nLanguagesPath = path.join(__dirname, '../../../../../../igniteui-angular-i18n/src/i18n'); +const errors = []; + +class i18nTests { + public runTests(): void { + this.i18nFilesMatchForAllLanguages(); + } + + public getDirectories = srcPath => fs.readdirSync(srcPath).filter(file => fs.statSync(path.join(srcPath, file)).isDirectory()); + public getFiles = srcPath => fs.readdirSync(srcPath).filter(file => fs.statSync(path.join(srcPath, file)).isFile()); + + public i18nFilesMatchForAllLanguages(): void { + this.getDirectories(i18nLanguagesPath).forEach(dir => { + const curDirPath = path.join(i18nLanguagesPath, dir); + if (this.getFiles(curDirPath).length !== this.getFiles(i18nProductPath).length) { + errors.push(`Not all i18n component files that are available for localization have matching files for ${dir} language. + Check and add the appropriate resource strings with EN translation and mark the PR as 'pending localization'` + ); + } + }); + if (errors.length > 0) { + throw errors; + } + } +} + +new i18nTests().runTests();