I have a REACTSjs application and am trying to solve a problem with localization.
I receive some text from the API in which there are some special characters marking the text that should be localized. Something like this:
This is a translated text: [labels.example]. Awesome!
I am using react-redux-localize to translate the keys so the result should look like this:
This is a translated text: <Translate id="labels.example" />. Awesome!
I tried solving this problem with renderHTML from react-render-html:
function localizeNames(text) {
text = text.replace("[", "<Translate id=\"");
text = text.replace("]", "\" />");
return text;
}
and calling this function in my render function:
<div>{renderHTML(localizeNames(text))}</div>
but it throws an exception:
Warning: The tag <translate> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
Can anybody help me with this use-case? I am quite new to javascript.