-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #466 from WildMeOrg/develop
PRs for v1.1.0 release
- Loading branch information
Showing
136 changed files
with
4,550 additions
and
2,077 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const { find } = require('find-in-files'); | ||
const englishTranslations = require('../locale/en.json'); | ||
|
||
const translationKeys = Object.keys(englishTranslations); | ||
let unusedCount = 0; | ||
|
||
function getLinesWithMatch(lines, substring) { | ||
return lines.filter(line => line.includes(substring)); | ||
} | ||
|
||
async function printUnusedKeys() { | ||
/* eslint-disable */ | ||
for await (const translationKey of translationKeys) { | ||
const results = await find(translationKey, './src'); | ||
const matches = Object.values(results); | ||
const trueMatches = matches.filter(match => { | ||
const matchingLines = match?.line || []; | ||
const linesWithSingleQuoteMatch = getLinesWithMatch( | ||
matchingLines, | ||
`"${translationKey}"`, | ||
); | ||
const linesWithDoubleQuoteMatch = getLinesWithMatch( | ||
matchingLines, | ||
`\'${translationKey}\'`, | ||
); | ||
return ( | ||
linesWithSingleQuoteMatch.length > 0 || | ||
linesWithDoubleQuoteMatch.length > 0 | ||
); | ||
}); | ||
if (trueMatches.length === 0) { | ||
unusedCount += 1; | ||
console.log(`"${translationKey}" may be unused.`); | ||
} | ||
} | ||
/* eslint-enable */ | ||
console.log( | ||
`Script finished. ${unusedCount} potentially unused translation keys found.`, | ||
); | ||
} | ||
|
||
console.log( | ||
'FYI, this script takes forever to run! Recommendation is to leave it running overnight or in the background.', | ||
); | ||
printUnusedKeys(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.