diff --git a/ComponentInterpolator.js b/ComponentInterpolator.js index 8d0bde0..975e299 100644 --- a/ComponentInterpolator.js +++ b/ComponentInterpolator.js @@ -1,25 +1,3 @@ -/** - * Given: - * - * Ohai {this.props.user}, click here right now please! - * - * Pre-process it into: - * - * , - * '**': , - * '***': }} - * /> - * - * Which is equivalent to: - * - * Ohai {this.props.user}, click here right now please! - * - * ... but completely localizable :) - */ - var React = require('react'); var cloneWithProps = require('react/lib/cloneWithProps'); var invariant = require('react/lib/invariant'); diff --git a/Translate.js b/Translate.js deleted file mode 100644 index a224a6f..0000000 --- a/Translate.js +++ /dev/null @@ -1,65 +0,0 @@ -/* -Given: - -Ohai {this.props.user}, click here right now please! - -Pre-process it into: - - - - - -*/ - -var React = require('react'); -var I18n = require('i18n'); -var invariant = require('react/lib/invariant'); -var { string } = React.PropTypes; - -var OWN_PROPS = ['defaultValue', 'translateKey', 'children']; - -var Translate = React.createClass({ - propTypes: { - translateKey: string, - defaultValue: string - }, - - componentWillMount() { - var textCount = this.textCount(); - var componentCount = this.componentCount(); - invariant( - textCount <= 1, - ' can only have one text child when not using pre-processing' - ); - invariant( - componentCount === 0, - ' cannot have any component children when not using pre-processing' - ); - invariant( - textCount === 1 || this.props.defaultValue || this.props.translateKey, - ' needs at least a translateKey, defaultValue, or text child' - ); - }, - - textCount(node) { - node = node || this; - count = 0; - React.Children.forEach(node.props.children, function(child) { - count += typeof child === 'string' ? 1 : this.textCount(child); - }); - return count; - }, - - render() { - var options = this.extraProps(); - var translateKey = this.props.translateKey; - var defaultValue = this.props.defaultValue || this.props.children; - options.defaultValue = defaultValue; - - var string = I18n.t(translateKey, options); - var children = this.inferChildren(string, this.props.children); - return React.createElement('span', {}, children); - } -}); - -module.exports = Translate;