2019-12-10 08:53:26 +01:00
|
|
|
#!/bin/env node
|
|
|
|
const fs = require('fs')
|
|
|
|
const merge = require('deepmerge')
|
|
|
|
const glob = require('glob')
|
|
|
|
|
|
|
|
glob('src/locales/!(messages).json', {}, (e, files) => {
|
|
|
|
let messages = []
|
|
|
|
for (const file of files) {
|
|
|
|
console.log(`Loading ${file}...`)
|
|
|
|
const locale_messages = require(`./${file}`)
|
|
|
|
messages.push(locale_messages)
|
|
|
|
}
|
|
|
|
console.log('Merging messages...')
|
2020-05-29 22:33:32 +02:00
|
|
|
if (messages && messages.length > 1) {
|
|
|
|
messages = merge.all(messages)
|
|
|
|
} else {
|
|
|
|
messages = messages[0] // single locale mode
|
|
|
|
}
|
2019-12-10 08:53:26 +01:00
|
|
|
fs.writeFileSync('src/locales/messages.json', JSON.stringify(messages), {})
|
|
|
|
})
|