flowchat-map-i18n
i18n output mapping for Flowchat
Getting started
Install
$ npm install --save flowchat-map-i18n
or
$ yarn add flowchat-map-i18n
Usage
app.js
import { Flowchat } from 'flowchat';
const FlowchatMapI18n = require('./flowchat-map-i18n.js');
const i18nMap = new FlowchatMapI18n();
i18nMap.configure({
locales:['en', 'pl'],
defaultLocale: 'en',
directory: __dirname + '/../locales'
});
const bot = new Flowchat();
bot.output
.map(i18nMap.output())
.subscribe(({ data, sessionId }) => {
console.log(data);
});
flows/helloI18n.js
import { send } from 'flowchat';
// const activator ...
// const reducer ...
const saga = function* (input, state, sessionId) {
yield send({ i18n: { phrase: 'hello', locale: state.locale } }, sessionId);
}