Skip to content

Commit e82234c

Browse files
authored
Merge pull request #10345 from IgniteUI/iganchev/add-tests-i18n
test(i18n): Check for missing i18n files
2 parents c7b0c23 + 66f2ef6 commit e82234c

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

.github/workflows/nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ jobs:
4141
npm run test:lib
4242
npm run test:styles
4343
npm run test:schematics
44+
npm run test:i18n
4445
env:
4546
NODE_OPTIONS: --max_old_space_size=4096
4647
- name: Build i18n & validate output

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"test:lib:watch": "ng test igniteui-angular --karma-config=./projects/igniteui-angular/karma.watch.conf.js",
2424
"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",
2525
"test:styles": "ts-node --skip-project ./node_modules/jasmine/bin/jasmine.js ./projects/igniteui-angular/src/lib/core/styles/spec/tests.ts",
26+
"test:i18n": "ts-node --skip-project ./projects/igniteui-angular/src/lib/core/i18n/tests/tests.ts",
2627
"build:lib": "ng build igniteui-angular --configuration production && gulp buildStyle",
2728
"build:style": "gulp buildStyle",
2829
"build:migration": "gulp copyMigrations && tsc --listEmittedFiles --project ./projects/igniteui-angular/migrations/tsconfig.json",
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
4+
const i18nProductPath = path.join(__dirname, '../');
5+
const i18nLanguagesPath = path.join(__dirname, '../../../../../../igniteui-angular-i18n/src/i18n');
6+
const errors = [];
7+
8+
class i18nTests {
9+
public runTests(): void {
10+
this.i18nFilesMatchForAllLanguages();
11+
}
12+
13+
public getDirectories = srcPath => fs.readdirSync(srcPath).filter(file => fs.statSync(path.join(srcPath, file)).isDirectory());
14+
public getFiles = srcPath => fs.readdirSync(srcPath).filter(file => fs.statSync(path.join(srcPath, file)).isFile());
15+
16+
public i18nFilesMatchForAllLanguages(): void {
17+
this.getDirectories(i18nLanguagesPath).forEach(dir => {
18+
const curDirPath = path.join(i18nLanguagesPath, dir);
19+
if (this.getFiles(curDirPath).length !== this.getFiles(i18nProductPath).length) {
20+
errors.push(`Not all i18n component files that are available for localization have matching files for ${dir} language.
21+
Check and add the appropriate resource strings with EN translation and mark the PR as 'pending localization'`
22+
);
23+
}
24+
});
25+
if (errors.length > 0) {
26+
throw errors;
27+
}
28+
}
29+
}
30+
31+
new i18nTests().runTests();

0 commit comments

Comments
 (0)