I have a JSON translation file like below
"results":{
"email-notification": "You have n mails"
}
where "n" will be a dynamic number. If 10 mails, I need to show "You have 10 mails". If 15 mails, I need to show "You have 15 mails".
How do I do this in ReactJS?
I know, in AngularJS, we can do it like below
<span ng-bind-html="results.email-notification|translate:mailCount"></span>
and in JSON
"results":{
"email-notification": "You have {{mailCount}} mails"
}
where mailCount is the number of mails.
How do I do the same thing in ReactJS?
The below given is the JSX file
import React, {Component} from 'react';
import jsonData from "../../../public/translation/results.json";
class Results extends Component {
var mailCount = 10;
render() {
return(
<div className="results">
<span className="result">{jsonData.results['email-notification']}</span>
</div>
);
}
}
export default Results
Suppose the mailCount is 10. How do I display it?