react-localize
A simple React Context wrapper and text localization component
for localizing strings.
Documentation:
Please refer to our gitbook documentation
for more detailed information & resources.
Getting Started, Quickly:
npm i react-localize
*or via yarn add react-localize
Example of usage:
import { LocalizationProvider, LocalizationConsumer } from 'react-localize';
const localizationBundle = {
'app.button.Submit': 'Submit',
foo: {
bar: 'Hey %s, you must be %d years old?'
}
};
<LocalizationProvider messages={localizationBundle}>
<AnyParentComponent>
<LocalizationConsumer>
{({ localize }) => {
return <div>
<h1>{localize('prop.MissingValue')}</h1>
<button>{localize('app.button.Submit')}</button>
<p>{localize('foo.bar', ['Stephen', 34])}</p>
</div>;
}}
</LocalizationConsumer>
</AnyParentComponent>
</LocalizationProvider>