summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/reducers/i18n.js
blob: 46df8fc460990fd679820af4db241c626b5a1590 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const { Record, Map } = require('immutable');
const ACTION_TYPES = require('../actions/TYPES');

const I18nState = Record({
    locale: 'en',
    // Map of locale -> Map<String:String>
    messages: Map()
});

function reduceI18n(state, action) {
    state = state || I18nState();
    switch (action.type) {

    case ACTION_TYPES.I18N_REGISTER_LOCALE:
        return state.merge({
            messages: state.messages.set(action.locale, Map(action.messages))
        });

    default:
        return state;

    }
}

module.exports = reduceI18n;