Add en localeMessages to test states.

feature/default_network_editable
Dan 7 years ago
parent ca5bce477e
commit edf63f8b51
  1. 5
      development/genStates.js
  2. 12
      development/get-locale-messages.js

@ -1,6 +1,7 @@
const fs = require('fs')
const path = require('path')
const promisify = require('pify')
const getLocaleMessages = require('./get-locale-messages')
start().catch(console.error)
@ -12,6 +13,10 @@ async function start () {
const stateFilePath = path.join(__dirname, 'states', stateFileName)
const stateFileContent = await promisify(fs.readFile)(stateFilePath, 'utf8')
const state = JSON.parse(stateFileContent)
const enLocaleMessages = await getLocaleMessages()
state.localeMessages = { en: enLocaleMessages, current: {} }
const stateName = stateFileName.split('.')[0].replace(/-/g, ' ', 'g')
states[stateName] = state
}))

@ -0,0 +1,12 @@
const fs = require('fs')
const path = require('path')
const promisify = require('pify')
async function getLocaleMessages () {
const localeMessagesPath = path.join(process.cwd(), 'app', '_locales', 'en', 'messages.json')
const enLocaleMessagesJSON = await promisify(fs.readFile)(localeMessagesPath)
const enLocaleMessages = JSON.parse(enLocaleMessagesJSON)
return enLocaleMessages
}
module.exports = getLocaleMessages
Loading…
Cancel
Save