From edf63f8b51ec0717e580ec69b495987a00062b92 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 22 Mar 2018 01:09:21 -0230 Subject: [PATCH] Add en localeMessages to test states. --- development/genStates.js | 5 +++++ development/get-locale-messages.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 development/get-locale-messages.js diff --git a/development/genStates.js b/development/genStates.js index bc274c757..1b21a42e5 100644 --- a/development/genStates.js +++ b/development/genStates.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 })) diff --git a/development/get-locale-messages.js b/development/get-locale-messages.js new file mode 100644 index 000000000..3b76a851d --- /dev/null +++ b/development/get-locale-messages.js @@ -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