yew/website/write-translations.js
Muhammad Hamza 3ad4dbe837
Format website with prettier (#2536)
* add prettier

* ci

* run prettier

* run prettier in CI

* run prettier --write

* ignore README.md

* specify googleAnalytics

* fmt

* npm run write-translations

* fmt

* ignore i18n json files

they're autogenerated and don't like being formatted

* post merge fixes & some updates

* post merge fixes
2022-04-06 22:52:15 +05:00

30 lines
752 B
JavaScript

const {
i18n: { locales },
} = require('./docusaurus.config.js')
const util = require('util')
const exec = util.promisify(require('child_process').exec)
/**
* @param {string} locale
*/
async function writeTranslation(locale) {
// exec rejects when the subprocess exits with non-zero code
const { stdout, stderr } = await exec(
`npm run docusaurus -- write-translations --locale ${locale}`
)
console.log(stdout)
console.error(stderr)
}
async function writeTranslations() {
for (const locale of locales.filter((locale) => locale !== 'en')) {
await writeTranslation(locale)
}
}
module.exports = writeTranslations
if (require.main === module) {
writeTranslations().catch((e) => console.error(e))
}