Heavily inspired by react-intl
yarn add @inkofpixel/react-light-translationsimport*asReactfrom'react';import*asReactDOMfrom'react-dom';import{IntlProvider,useIntl}from'@inkofpixel/react-light-translations';constmessages={it: require('./lang/it.json'),en: require('./lang/en.json'),};constApp=()=>{constlocale='en';return(<IntlProviderlocale={locale}messages={messages[locale]asRecord<string,string>}><TestApp/></IntlProvider>);};functionTestApp(){const{ formatMessage }=useIntl();return(<div><div>{formatMessage({id: 'test'})}</div><div>{formatMessage({id: 'testWithVariable'},{variable: 'VARIABLE',})}</div><div>{formatMessage({id: 'testWithElementVariable'},{variable: (<spanstyle={{fontWeight: 'bold'}}>VARIABLE ELEMENT</span>),})}</div><div>{formatMessage({id: 'testWithElementVariable'},{variable: (<spanstyle={{color: 'red'}}>{formatMessage({id: 'test'})}</span>),})}</div></div>);}ReactDOM.render(<App/>,document.getElementById('root'));