Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

lint-translation-files.js 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  1. #!/usr/bin/env node
  2. const { execSync } = require('child_process')
  3. // [start-readme]
  4. //
  5. // Use this script as part of the Crowdin merge process to output a list of parsing and rendering
  6. // errors in translated files and run script/reset-translated-file.js on them.
  7. //
  8. // [end-readme]
  9. const parsingErrorsLog = '~/docs-translation-parsing-error.txt'
  10. const renderErrorsLog = '~/docs-translation-rendering-error.txt'
  11. // 1. Check for parsing errors and output to file. Note this one must be run FIRST.
  12. console.log('Checking for parsing errors...')
  13. try {
  14. execSync(`TEST_TRANSLATION=true npx jest linting/lint-files > ${parsingErrorsLog}`)
  15. } catch (error) {
  16. console.log('There were new parsing errors!')
  17. }
  18. // 2. Check for rendering errors and output to file. Note this one must be run SECOND.
  19. console.log('Checking for rendering errors...')
  20. try {
  21. execSync(`script/test-render-translation.js > ${renderErrorsLog}`)
  22. } catch (error) {
  23. console.log('There were new rendering errors!')
  24. }
  25. // Reset the broken files.
  26. console.log('Resetting broken files...')
  27. execSync(`cat ${parsingErrorsLog} ${renderErrorsLog} | egrep "^translations/.*/(.+.md|.+.yml)$" | uniq | xargs -L1 script/reset-translated-file.js --prefer-main`)
  28. // Print a message with next steps.
  29. console.log(`Success!
  30. Verify changes with git status and then run:
  31. git commit --no-verify -m "Reverted translated files with parsing and rendering errors"
  32. `)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...