tabby/scripts/i18n-extract.js

28 lines
912 B
JavaScript
Raw Normal View History

2022-01-08 16:02:56 +01:00
#!/usr/bin/env node
const sh = require('shelljs')
const fs = require('fs/promises')
const vars = require('./vars')
const log = require('npmlog')
const tempOutput = 'locale/app.new.pot'
const pot = 'locale/app.pot'
const tempHtml = 'locale/tmp-html'
;(async () => {
sh.mkdir('-p', tempHtml)
for (const plugin of vars.builtinPlugins) {
log.info('extract-pug', plugin)
2022-01-16 19:41:01 +01:00
sh.exec(`yarn pug --doctype html -s --pretty -O '{require: function(){}}' -o ${tempHtml}/${plugin} ${plugin}`, { fatal: true })
2022-01-08 16:02:56 +01:00
log.info('extract-ts', plugin)
2022-01-16 19:41:01 +01:00
sh.exec(`node node_modules/.bin/ngx-translate-extract -i ${plugin}/src -m -s -f pot -o ${tempOutput}`, { fatal: true })
2022-01-08 16:02:56 +01:00
}
log.info('extract-pug')
2022-01-16 19:41:01 +01:00
sh.exec(`node node_modules/.bin/ngx-translate-extract -i ${tempHtml} -f pot -s -o ${tempOutput}`, { fatal: true })
2022-01-08 16:02:56 +01:00
sh.rm('-r', tempHtml)
await fs.rename(tempOutput, pot)
})()