martinandert / react-translate-component

A component for React that utilizes the Counterpart module to provide multi-lingual/localized text content.
MIT License
322 stars 31 forks source link

Add support for html in fallback attribute #9

Closed frg closed 8 years ago

frg commented 9 years ago

Is it possible for the fallback attribute to accept html content?

<Translate content="core.helloworld" fallback="<h1>Translation not found for "hello world".</h1>" />
martinandert commented 8 years ago

Hi Jean, sorry for the delay. The fallback attribute currently does not accept HTML content because of security considerations and because translations can also be used as attribute values (e.g. the title attribute of an img element).

I am closing this for now but nonetheless I am always open for discussion and pull requests.

frg commented 8 years ago

If anyone is looking for a similar solution I found adding the attribute "unsafe" works. BUT of course as the name states. It's unsafe.

I don't think this is a common use case but as I'm working with an existing translation module I have no way around this.

''' <Translate content={ this.props.translateKey } fallback="

Translation not found.

" unsafe /> ); '''

Thanks for the great work @martinandert