React i18n break lines in JSON String React i18n break lines in JSON String reactjs reactjs

React i18n break lines in JSON String


You can do it with css white-space: pre-line; & \n in the translation text.

const root = document.getElementById('root');i18next.init({  lng: 'en',  resources: {    en: {      translation: {        "key": "Hello world\nThis sentence should appear on the second line"      }    }  }}, function(err, t) {  // initialized and ready to go!  root.innerHTML = i18next.t('key');});
#root {  white-space: pre-line;}
<script src="https://unpkg.com/i18next@15.0.9/dist/umd/i18next.min.js"></script><div id="root"></div>