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

Commit

Permalink
feat(checkmissingtranslations.ts): refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosvega91 committed May 3, 2020
1 parent ecab41d commit 75f9981
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
"redux-mock-store": "~1.5.4",
"source-map-explorer": "^2.2.2",
"standard-version": "~7.1.0",
"ts-jest": "~24.3.0"
"ts-jest": "~24.3.0",
"ts-node": "^8.10.0"
},
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
Expand Down
10 changes: 5 additions & 5 deletions scripts/checkMissingTranslations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import i18n from '../src/i18n'
const checkRecursiveTranslation = (
searchingPath: string,
defaultLanguageObject: ResourceKey,
translatedLanguageObject: ResourceKey,
comparingLanguageObject: ResourceKey,
) => {
if (typeof defaultLanguageObject === 'string' || typeof translatedLanguageObject === 'string') {
if (typeof defaultLanguageObject === 'string' || typeof comparingLanguageObject === 'string') {
if (typeof defaultLanguageObject === 'object') {
console.log(
`📙 Found a string for path ${searchingPath} while is and object for the default language`,
Expand All @@ -15,18 +15,18 @@ const checkRecursiveTranslation = (
return
}
const defaultKeys: string[] = Object.keys(defaultLanguageObject)
const translatedKeys: string[] = Object.keys(translatedLanguageObject)
const translatedKeys: string[] = Object.keys(comparingLanguageObject)
if (defaultKeys.length === 0 || translatedKeys.length === 0) {
return
}
defaultKeys.forEach((key) => {
if (!translatedLanguageObject[key]) {
if (!comparingLanguageObject[key]) {
console.log(`📙 The key ${key} is not present for path ${searchingPath}`)
} else {
checkRecursiveTranslation(
`${searchingPath}-->${key}`,
defaultLanguageObject[key],
translatedLanguageObject[key],
comparingLanguageObject[key],
)
}
})
Expand Down

0 comments on commit 75f9981

Please # to comment.