<commit_before>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';

import Dropdown from 'components/ui/dropdown';

import './styles.scss';

class SentenceSelector extends PureComponent {
  static defaultProps = {
    sentence: 'Displaying {name} for {selector}'
  };

  reduceSentence = (sentence, pattern, component) => {
    const split = sentence.split(pattern);
    return [split[0], component, split[1]];
  };

  render() {
    const { onChange, className, options, value, sentence, name } = this.props;

    const nameRepl =
      sentence.includes('{name}') && name
        ? this.reduceSentence(sentence, '{name}', name).join('')
        : sentence;
    const selectorRepl = this.reduceSentence(
      nameRepl,
      '{selector}',
      <Dropdown
        key={name || `${value}-${sentence}`}
        className="sentence-dropdown"
        theme="theme-dropdown-native-button"
        value={value}
        options={options}
        onChange={onChange}
        native
      />
    );

    return (
      <div className={`c-sentence-selector ${className || ''}`}>
        {selectorRepl}
      </div>
    );
  }
}

SentenceSelector.propTypes = {
  className: PropTypes.string,
  value: PropTypes.oneOfType([
    PropTypes.number,
    PropTypes.string,
    PropTypes.object
  ]),
  onChange: PropTypes.func,
  options: PropTypes.array,
  sentence: PropTypes.string,
  name: PropTypes.string
};

export default SentenceSelector;<commit_msg>translate legend selector menus components<commit_after>import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { translateText } from 'utils/transifex';

import Dropdown from 'components/ui/dropdown';

import './styles.scss';

class SentenceSelector extends PureComponent {
  static defaultProps = {
    sentence: 'Displaying {name} for {selector}'
  };

  reduceSentence = (sentence, pattern, component) => {
    const split = sentence.split(pattern);
    return [split[0], component, split[1]];
  };

  render() {
    const { onChange, className, options, value, sentence, name } = this.props;

    const translateSentence = translateText(sentence);
    const nameRepl =
      translateSentence.includes('{name}') && name
        ? this.reduceSentence(translateSentence, '{name}', name).join('')
        : sentence;

    const selectorRepl = this.reduceSentence(
      nameRepl,
      '{selector}',
      <Dropdown
        key={name || `${value}-${sentence}`}
        className="sentence-dropdown"
        theme="theme-dropdown-native-button"
        value={value}
        options={options}
        onChange={onChange}
        native
      />
    );

    return (
      <div className={`c-sentence-selector notranslate ${className || ''}`}>
        {selectorRepl}
      </div>
    );
  }
}

SentenceSelector.propTypes = {
  className: PropTypes.string,
  value: PropTypes.oneOfType([
    PropTypes.number,
    PropTypes.string,
    PropTypes.object
  ]),
  onChange: PropTypes.func,
  options: PropTypes.array,
  sentence: PropTypes.string,
  name: PropTypes.string
};

export default SentenceSelector;
{'fraction_non_alphanumeric': 0.13496143958868895, 'fraction_numerical': 0.0012853470437017994, 'mean_word_length': 3.1841397849462365, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6268932', 'n_tokens_mistral': 905, 'n_tokens_neox': 908, 'n_words': 197}