Skip to content

Repository files navigation

Uber minimal translation library for React

Heavily inspired by react-intl

yarn add @inkofpixel/react-light-translations
import*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'));

About

Uber light and minimal translations helper for React

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages