1
0
mirror of synced 2025-12-21 02:46:50 -05:00
Files
docs/script/helpers/find-extraneous-translation-files.js
Jason Etcovitch 8d4f3e65fe Move test & script utils out of /lib (#17517)
* Remove an unused file

* Move authenticate-to-aws to scripts/utils

* Move crowdin-config to tests/utils

* Remove add-frontmatter-to-file

* Move find-unused-assets

* Move git-utils to script/utils

* Move lib/github to script/utils

* Revert "Remove an unused file"

This reverts commit cd93ad846a0354e957359f23124eb0724c9147cf.

* Move find-extraneous-translation-files to script/utils

* We already have tests/helpers

* Rename script/utils => helpers for consistency

* Forgot a path

* Fix path to crowdin-config

Co-authored-by: Chiedo John <2156688+chiedo@users.noreply.github.com>
2021-01-29 10:30:51 -05:00

29 lines
920 B
JavaScript

const path = require('path')
const { difference } = require('lodash')
const walk = require('walk-sync').entries
const languages = require('../../lib/languages')
module.exports = function findExtraneousTranslatedFiles () {
const files = []
const relativePaths = {}
// group page.relativePath lists by language
for (const languageCode in languages) {
const language = languages[languageCode]
const languageDir = path.join(__dirname, '..', language.dir)
relativePaths[languageCode] = walk(languageDir, { directories: false })
.map(file => file.relativePath)
}
for (const languageCode in languages) {
if (languageCode === 'en') continue
const language = languages[languageCode]
/* istanbul ignore next */
difference(relativePaths[languageCode], relativePaths.en).forEach(file => {
files.push(path.join(__dirname, '..', language.dir, file))
})
}
return files
}