1
0
mirror of synced 2025-12-20 02:19:14 -05:00
Files
docs/script/backfill-missing-localizations.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

39 lines
1.2 KiB
JavaScript
Executable File

#!/usr/bin/env node
const fs = require('fs')
const path = require('path')
const walk = require('walk-sync')
const mkdirp = require('mkdirp').sync
const languages = require('../lib/languages')
const dirs = ['content', 'data']
// [start-readme]
//
// This script copies any English files that are missing from the translations directory into the translations directory.
// We only need to run this if problems occur with Crowdin's automatic sync.
//
// [end-readme]
dirs.forEach(dir => {
const englishPath = path.join(__dirname, `../${dir}`)
const filenames = walk(englishPath)
.filter(filename => {
return (filename.endsWith('.yml') || filename.endsWith('.md')) &&
!filename.endsWith('README.md')
})
filenames.forEach(filename => {
Object.values(languages).forEach(language => {
if (language.code === 'en') return
const fullPath = path.join(__dirname, '..', language.dir, dir, filename)
if (!fs.existsSync(fullPath)) {
console.log('missing', fullPath)
const englishFullPath = path.join(__dirname, '..', dir, filename)
mkdirp(path.dirname(fullPath))
fs.writeFileSync(fullPath, fs.readFileSync(englishFullPath))
}
})
})
})