<commit_before>import React from 'react';
import i18n from 'i18n-js';
import _marked from 'marked';

/*
 * Make sure that we sanitize html markup in the MD compiler
 */
_marked.setOptions({
  sanitize: true
});

function _render(props, content) {
  return React.createElement(
    this.props.inline ? 'span' : 'div', props, content
  );
}

/**
 * A widget for internationalisation of text.
 *
 * == How to use an I18n component:
 *
 * In your file:
 *
 *   import I18n from 'carbon/lib/components/i18n';
 *
 * To render the message:
 *
 *  <I18n translationKey='foo' />
 *
 * For additional properties specific to this component, see propTypes.
 *
 * @class I18n
 * @constructor
 */
class I18n extends React.Component {

  static propTypes = {

    /**
     * Whether to compile the value as markdown
     *
     * @property markdown
     * @type {Boolean}
     * @default false
     */
    markdown: React.PropTypes.bool,

    /**
     * Whether to enclose the text in a <span> or a <div>
     *
     * @property inline
     * @type {Boolean}
     * @default true
     */
    inline: React.PropTypes.bool,

    /**
     * The key to lookup for a localised value
     *
     * @property translationKey
     * @type {String}
     * @default undefined
     */
    translationKey: React.PropTypes.string
  }

  static defaultProps = {
    inline: true
  }

  get marked() {
    return this.props.inline ? str => _marked.inlineLexer(str, []) : _marked;
  }

  renderMarkdown() {
    return _render.call(this, {
      dangerouslySetInnerHTML: {
        __html: this.marked(i18n.t(this.props.translationKey))
      }
    });
  }

  renderDefault() {
    return _render.call(this, {}, i18n.t(this.props.translationKey));
  }

  /**
   * Renders the component.
   *
   * @method render
   */
  render() {
    return this.props.markdown ? this.renderMarkdown() : this.renderDefault();
  }

}

export default I18n;<commit_msg>refactored component to remove unnecessary public access to essentially private functions<commit_after>import React from 'react';
import i18n from 'i18n-js';
import _marked from 'marked';

/*
 * Make sure that we sanitize html markup in the MD compiler
 */
_marked.setOptions({
  sanitize: true
});

/**
 * A widget for internationalisation of text.
 *
 * == How to use an I18n component:
 *
 * In your file:
 *
 *   import I18n from 'carbon/lib/components/i18n';
 *
 * To render the message:
 *
 *  <I18n translationKey='foo' />
 *
 * For additional properties specific to this component, see propTypes.
 *
 * @class I18n
 * @constructor
 */
class I18n extends React.Component {

  static propTypes = {

    /**
     * Whether to compile the value as markdown
     *
     * @property markdown
     * @type {Boolean}
     * @default false
     */
    markdown: React.PropTypes.bool,

    /**
     * Whether to enclose the text in a <span> or a <div>
     *
     * @property inline
     * @type {Boolean}
     * @default true
     */
    inline: React.PropTypes.bool,

    /**
     * The key to lookup for a localised value
     *
     * @property translationKey
     * @type {String}
     * @default undefined
     */
    translationKey: React.PropTypes.string
  }

  static defaultProps = {
    inline: true
  }

  constructor(props) {
    super(props);

    const self = this;
    const marked = self.props.inline ? str => _marked.inlineLexer(str, []) : _marked;

    function _render(props, content) {
      return React.createElement(
        self.props.inline ? 'span' : 'div', props, content
      );
    }

    function renderMarkdown() {
      return _render({
        dangerouslySetInnerHTML: {
          __html: marked(i18n.t(self.props.translationKey))
        }
      });
    }

    function renderDefault() {
      return _render({}, i18n.t(self.props.translationKey));
    }

    /**
     * Renders the component.
     *
     * @method render
     */
    self.render = function() {
      return self.props.markdown ? renderMarkdown() : renderDefault();
    };
  }
}

export default I18n;
{'fraction_non_alphanumeric': 0.1199900423201394, 'fraction_numerical': 0.01095344784665173, 'mean_word_length': 2.509170305676856, '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': '5257854', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1238, 'n_words': 342}