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

backfill-missing-localizations.js 1.2 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
  1. #!/usr/bin/env node
  2. const fs = require('fs')
  3. const path = require('path')
  4. const walk = require('walk-sync')
  5. const mkdirp = require('mkdirp').sync
  6. const languages = require('../lib/languages')
  7. const dirs = ['content', 'data']
  8. // [start-readme]
  9. //
  10. // This script copies any English files that are missing from the translations directory into the translations directory.
  11. // We only need to run this if problems occur with Crowdin's automatic sync.
  12. //
  13. // [end-readme]
  14. dirs.forEach(dir => {
  15. const englishPath = path.join(__dirname, `../${dir}`)
  16. const filenames = walk(englishPath)
  17. .filter(filename => {
  18. return (filename.endsWith('.yml') || filename.endsWith('.md')) &&
  19. !filename.endsWith('README.md')
  20. })
  21. filenames.forEach(filename => {
  22. Object.values(languages).forEach(language => {
  23. if (language.code === 'en') return
  24. const fullPath = path.join(__dirname, '..', language.dir, dir, filename)
  25. if (!fs.existsSync(fullPath)) {
  26. console.log('missing', fullPath)
  27. const englishFullPath = path.join(__dirname, '..', dir, filename)
  28. mkdirp(path.dirname(fullPath))
  29. fs.writeFileSync(fullPath, fs.readFileSync(englishFullPath))
  30. }
  31. })
  32. })
  33. })
Tip!

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

Comments

Loading...