<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { availableLocales } from '../../../containers/IntlWrapper';
import { changeLocale } from '../../../actions/locale';

require('./LocaleSelector.scss');


const LocaleSelectorItem = ({ locale, currentLocale, handleLocaleSelection }) => {
  const styleClasses = ['LocaleSelectorItem'];
  if (locale.tag === currentLocale) {
    styleClasses.push('LocaleSelectorItemSelected');
  }
  const classNames = styleClasses.join(' ');
  return (
    <button
      type="button"
      onClick={handleLocaleSelection}
      className={classNames}
      data-value={locale.tag}
    >
      { locale.label }
    </button>
  );
};

LocaleSelectorItem.propTypes = {
  locale: PropTypes.object.isRequired,
  currentLocale: PropTypes.string.isRequired,
  handleLocaleSelection: PropTypes.func.isRequired,
};

class LocaleSelector extends React.Component {
  constructor(props) {
    super(props);
    this.handleLocaleSelection = this.handleLocaleSelection.bind(this);
  }

  handleLocaleSelection(e) {
    const currentLocale = this.props.locale;
    const newLocale = e.currentTarget.dataset.value;
    if (currentLocale !== newLocale) {
      window.localStorage.setItem('locale', newLocale);
      const { dispatch } = this.props;
      dispatch(changeLocale(newLocale));
    }
  }

  render() {
    const { locale } = this.props;
    return (
      <div>
        {availableLocales.map(l => (
          <LocaleSelectorItem
            key={l.tag}
            locale={l}
            handleLocaleSelection={this.handleLocaleSelection}
            currentLocale={locale}
          />
        ))}
      </div>
    );
  }
}

LocaleSelector.propTypes = {
  locale: PropTypes.string,
  dispatch: PropTypes.func,
};

function mapStateToProps(state) {
  return {
    locale: state.locale,
  };
}
export default connect(mapStateToProps)(LocaleSelector);<commit_msg>[#2245] Code style fixes<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { availableLocales } from '../../../containers/IntlWrapper';
import { changeLocale } from '../../../actions/locale';

require('./LocaleSelector.scss');


const LocaleSelectorItem = ({ locale, currentLocale, handleLocaleSelection }) => {
  const styleClasses = ['LocaleSelectorItem'];
  if (locale.tag === currentLocale) {
    styleClasses.push('LocaleSelectorItemSelected');
  }
  const classNames = styleClasses.join(' ');
  return (
    <button
      type="button"
      onClick={handleLocaleSelection}
      className={classNames}
      data-value={locale.tag}
    >
      { locale.label }
    </button>
  );
};

LocaleSelectorItem.propTypes = {
  locale: PropTypes.object.isRequired,
  currentLocale: PropTypes.string.isRequired,
  handleLocaleSelection: PropTypes.func.isRequired,
};

class LocaleSelector extends React.Component {
  constructor(props) {
    super(props);
    this.handleLocaleSelection = this.handleLocaleSelection.bind(this);
  }

  handleLocaleSelection(e) {
    const { locale } = this.props;
    const newLocale = e.currentTarget.dataset.value;
    if (locale !== newLocale) {
      window.localStorage.setItem('locale', newLocale);
      const { dispatch } = this.props;
      dispatch(changeLocale(newLocale));
    }
  }

  render() {
    const { locale } = this.props;
    return (
      <div>
        {availableLocales.map(l => (
          <LocaleSelectorItem
            key={l.tag}
            locale={l}
            handleLocaleSelection={this.handleLocaleSelection}
            currentLocale={locale}
          />
        ))}
      </div>
    );
  }
}

LocaleSelector.propTypes = {
  locale: PropTypes.string.isRequired,
  dispatch: PropTypes.func.isRequired,
};

function mapStateToProps(state) {
  return {
    locale: state.locale,
  };
}
export default connect(mapStateToProps)(LocaleSelector);
{'fraction_non_alphanumeric': 0.1328600405679513, 'fraction_numerical': 0.0010141987829614604, 'mean_word_length': 3.192348565356004, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '531929', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1130, 'n_words': 204}