{"size": 509, "ext": "js", "max_stars_repo_path": "src/i18n/redux/reducers.js", "max_stars_repo_name": "angeloocana/pool-tile-designer", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/i18n/redux/reducers.js", "max_issues_repo_name": "angeloocana/pool-tile-designer", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/i18n/redux/reducers.js", "max_forks_repo_name": "angeloocana/pool-tile-designer", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18.1785714286, "max_line_length": 62, "alphanum_fraction": 0.6149312377}
import { actions } from './actions';
import { addLocaleData } from 'react-intl';

const getI18n = (langKey) => {
  addLocaleData(require(`react-intl/locale-data/${langKey}`));

  return {
    langKey,
    messages: require(`../messages/${langKey}`)
  };
};

const i18n = (state, action) => {
  switch (action.type) {
  case actions.CHANGE_LANG:
    return {
      langKey: action.langKey,
      messages: getI18n(action.langKey)
    };
  default:
    return state || getI18n('en');
  }
};

export {
  i18n
};
