Skip to content

Commit

Permalink
Translate: Added support for “html” prop
Browse files Browse the repository at this point in the history
When present or “true” will use dangerouslySetInnerHTML to set value
  • Loading branch information
alexblunck committed Nov 4, 2017
1 parent 3f42e0f commit 8563a65
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib/Translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ import Base from './Base'
export default class Translate extends Base {

static propTypes = {
value: PropTypes.string.isRequired
value: PropTypes.string.isRequired,
html: PropTypes.bool,
className: PropTypes.string
}

render() {
const { className, value } = this.props
const { value, html, className } = this.props
const translation = I18n.translate(value)

return (
<span className={className}>{translation}</span>
)
if (html) {
return <span className={className} dangerouslySetInnerHTML={{ __html: translation }}></span>
} else {
return <span className={className}>{translation}</span>
}
}

}

0 comments on commit 8563a65

Please sign in to comment.