mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #11674 from overleaf/jpa-check-extracted-translations-in-ci
[web] check extracted translations in CI GitOrigin-RevId: 27e13f5fd1fe08db65b68ffbff639adb83d99f74
This commit is contained in:
parent
9ff8d93ab8
commit
663aace586
2 changed files with 36 additions and 0 deletions
|
@ -8,6 +8,27 @@ node scripts/translations/sort.js --check
|
|||
# Ensure all locales are still in use
|
||||
node scripts/translations/cleanupUnusedLocales.js --check
|
||||
|
||||
# Ensure all locales used in the frontend are tracked
|
||||
OUTPUT=data/dumpFolder/i18next-scanner
|
||||
trap "rm -rf $OUTPUT" EXIT
|
||||
npx i18next-scanner --output "$OUTPUT"
|
||||
ACTUAL=frontend/extracted-translations.json
|
||||
EXPECTED="$OUTPUT/frontend/extracted-translations.json"
|
||||
if ! diff "$ACTUAL" "$EXPECTED"; then
|
||||
cat <<MSG >&2
|
||||
|
||||
services/web/frontend/extracted-translations.json is not up-to-date.
|
||||
|
||||
---
|
||||
Try running:
|
||||
|
||||
internal$ bin/run web npm run extract-translations
|
||||
|
||||
---
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure no locales contain single quotes.
|
||||
LOCALES_WITH_SINGLE_QUOTE=$(\
|
||||
grep \
|
||||
|
|
|
@ -6,12 +6,23 @@ const EN_JSON = Path.join(__dirname, '../../locales/en.json')
|
|||
const CHECK = process.argv.includes('--check')
|
||||
const SYNC_NON_EN = process.argv.includes('--sync-non-en')
|
||||
|
||||
const COUNT_SUFFIXES = [
|
||||
'_plural',
|
||||
'_zero',
|
||||
'_one',
|
||||
'_two',
|
||||
'_few',
|
||||
'_many',
|
||||
'_other',
|
||||
]
|
||||
|
||||
async function main() {
|
||||
const locales = JSON.parse(await fs.promises.readFile(EN_JSON, 'utf-8'))
|
||||
|
||||
const src = execSync(
|
||||
// - find all the app source files in web
|
||||
// - exclude data files
|
||||
// - exclude list of locales used in frontend
|
||||
// - exclude locales files
|
||||
// - exclude public assets
|
||||
// - exclude third-party dependencies
|
||||
|
@ -19,6 +30,7 @@ async function main() {
|
|||
`
|
||||
find . -type f \
|
||||
-not -path './data/*' \
|
||||
-not -path './frontend/extracted-translations.json' \
|
||||
-not -path './locales/*' \
|
||||
-not -path './public/*' \
|
||||
-not -path '*node_modules/*' \
|
||||
|
@ -75,6 +87,9 @@ async function main() {
|
|||
let m
|
||||
while ((m = matcher.exec(src))) {
|
||||
found.add(m[0])
|
||||
for (const suffix of COUNT_SUFFIXES) {
|
||||
found.add(m[0] + suffix)
|
||||
}
|
||||
}
|
||||
|
||||
const unusedKeys = []
|
||||
|
|
Loading…
Reference in a new issue