Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit b3da0ee

Browse files
committed
refactor(checktranslations): run script as js file
now ts-node library is no need anymore because the script is compiled to javascript
1 parent 1b4fc4a commit b3da0ee

File tree

6 files changed

+69
-112
lines changed

6 files changed

+69
-112
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build
2+
bin
23
# Logs
34
logs
45
*.log

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@
102102
"redux-mock-store": "~1.5.4",
103103
"source-map-explorer": "^2.2.2",
104104
"standard-version": "~8.0.0",
105-
"ts-jest": "~24.3.0",
106-
"ts-node": "^8.10.0"
105+
"ts-jest": "~24.3.0"
107106
},
108107
"scripts": {
109108
"analyze": "source-map-explorer 'build/static/js/*.js'",
@@ -118,7 +117,7 @@
118117
"lint-staged": "lint-staged",
119118
"commitlint": "commitlint",
120119
"coveralls": "npm run test:ci -- --coverage --watchAll=false && cat ./coverage/lcov.info",
121-
"translation:check": "ts-node-script scripts/checkMissingTranslations.ts"
120+
"translation:check": "cd scripts && tsc && node ../bin/scripts/checkMissingTranslations.js"
122121
},
123122
"browserslist": {
124123
"production": [

scripts/checkMissingTranslations.ts

+2-48
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,7 @@
11
import chalk from 'chalk'
2-
import { Resource, ResourceKey } from 'i18next'
2+
import { ResourceKey } from 'i18next'
33

4-
import translationAR from '../src/locales/ar/translations'
5-
import translationDE from '../src/locales/de/translations'
6-
import translationEnUs from '../src/locales/enUs/translations'
7-
import translationES from '../src/locales/es/translations'
8-
import translationFR from '../src/locales/fr/translations'
9-
import translationIN from '../src/locales/in/translations'
10-
import translationIT from '../src/locales/it/translations'
11-
import translationJA from '../src/locales/ja/translations'
12-
import translationPtBR from '../src/locales/ptBr/translations'
13-
import translationRU from '../src/locales/ru/translations'
14-
import translationZR from '../src/locales/zr/translations'
15-
16-
const resources: Resource = {
17-
it: {
18-
translation: translationIT,
19-
},
20-
ar: {
21-
translation: translationAR,
22-
},
23-
de: {
24-
translation: translationDE,
25-
},
26-
en: {
27-
translation: translationEnUs,
28-
},
29-
es: {
30-
translation: translationES,
31-
},
32-
fr: {
33-
translation: translationFR,
34-
},
35-
in: {
36-
translation: translationIN,
37-
},
38-
ja: {
39-
translation: translationJA,
40-
},
41-
pt: {
42-
translation: translationPtBR,
43-
},
44-
ru: {
45-
translation: translationRU,
46-
},
47-
zr: {
48-
translation: translationZR,
49-
},
50-
}
4+
import resources from '../src/locales'
515

526
const error = chalk.bold.red
537
const warning = chalk.keyword('orange')

scripts/tsconfig.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"include": ["./checkMissingTranslations.ts"],
33
"compilerOptions": {
4-
"declaration": true,
5-
"declarationDir": "./dist",
64
"module": "commonjs",
7-
"outDir": "./dist",
5+
"outDir": "../bin",
86
"target": "es5"
97
}
108
}

src/i18n.ts

+1-58
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,7 @@ import i18n from 'i18next'
22
import LanguageDetector from 'i18next-browser-languagedetector'
33
import { initReactI18next } from 'react-i18next'
44

5-
import translationAR from './locales/ar/translations'
6-
import translationDE from './locales/de/translations'
7-
import translationEnUs from './locales/enUs/translations'
8-
import translationES from './locales/es/translations'
9-
import translationFR from './locales/fr/translations'
10-
import translationID from './locales/id/translations'
11-
import translationIT from './locales/it/translations'
12-
import translationJA from './locales/ja/translations'
13-
import translationPtBR from './locales/ptBr/translations'
14-
import translationRU from './locales/ru/translations'
15-
import translationZhCN from './locales/zhCN/translations'
16-
17-
const resources: { [language: string]: any } = {
18-
it: {
19-
name: 'Italian',
20-
translation: translationIT,
21-
},
22-
ar: {
23-
name: 'Arabic',
24-
translation: translationAR,
25-
},
26-
de: {
27-
name: 'German',
28-
translation: translationDE,
29-
},
30-
en: {
31-
name: 'English, American',
32-
translation: translationEnUs,
33-
},
34-
es: {
35-
name: 'Spanish',
36-
translation: translationES,
37-
},
38-
fr: {
39-
name: 'French',
40-
translation: translationFR,
41-
},
42-
id: {
43-
name: 'Indonesian',
44-
translation: translationID,
45-
},
46-
ja: {
47-
name: 'Japanese',
48-
translation: translationJA,
49-
},
50-
ptBR: {
51-
name: 'Portuguese',
52-
translation: translationPtBR,
53-
},
54-
ru: {
55-
name: 'Russian',
56-
translation: translationRU,
57-
},
58-
zhCN: {
59-
name: 'Chinese',
60-
translation: translationZhCN,
61-
},
62-
}
5+
import resources from './locales'
636

647
i18n
658
// load translation using xhr -> see /public/locales

src/locales/index.ts

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Resource } from 'i18next'
2+
3+
import translationAR from './ar/translations'
4+
import translationDE from './de/translations'
5+
import translationEnUs from './enUs/translations'
6+
import translationES from './es/translations'
7+
import translationFR from './fr/translations'
8+
import translationID from './id/translations'
9+
import translationIT from './it/translations'
10+
import translationJA from './ja/translations'
11+
import translationPtBR from './ptBr/translations'
12+
import translationRU from './ru/translations'
13+
import translationZhCN from './zhCN/translations'
14+
15+
const resources: Resource = {
16+
it: {
17+
name: 'Italian',
18+
translation: translationIT,
19+
},
20+
ar: {
21+
name: 'Arabic',
22+
translation: translationAR,
23+
},
24+
de: {
25+
name: 'German',
26+
translation: translationDE,
27+
},
28+
en: {
29+
name: 'English, American',
30+
translation: translationEnUs,
31+
},
32+
es: {
33+
name: 'Spanish',
34+
translation: translationES,
35+
},
36+
fr: {
37+
name: 'French',
38+
translation: translationFR,
39+
},
40+
id: {
41+
name: 'Indonesian',
42+
translation: translationID,
43+
},
44+
ja: {
45+
name: 'Japanese',
46+
translation: translationJA,
47+
},
48+
ptBR: {
49+
name: 'Portuguese',
50+
translation: translationPtBR,
51+
},
52+
ru: {
53+
name: 'Russian',
54+
translation: translationRU,
55+
},
56+
zhCN: {
57+
name: 'Chinese',
58+
translation: translationZhCN,
59+
},
60+
}
61+
62+
export default resources

0 commit comments

Comments
 (0)