react-node-polyglot

2.0.5 • Public • Published

React Node Pyloglot Build Status

React component to use node-polyglot

Install

npm install react-node-polyglot

You also need to install peer dependencies by yourself

npm install node-polyglot // v2.x.x
npm install react // v16.x.x
npm install prop-types // v15.x.x

This module targets Node.js 8 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers use Babel compiler.

Usage

const { Provider, withPolyglot, useT, useLocale } = require('react-node-polyglot');
 
 
const PolyglotHOC = withPolyglot(({ t, locale }) => {
  // locale object that is passed to provider
  return t('phrase');
});
 
const PolyglotHook = () => {
  // locale object that is passed to provider
  const locale = useLocale();
 
  const t = useT();
  return t('phrase');
};
 
const App = () => (
  <Provider locale={{ dictionary }}>
    <PolyglotHOC />
    <PolyglotHook />
  </Provider>
);

License

MIT © Abylay Keldibek

Readme

Keywords

Package Sidebar

Install

npm i react-node-polyglot

Weekly Downloads

1

Version

2.0.5

License

MIT

Unpacked Size

6.63 kB

Total Files

13

Last publish

Collaborators

  • atomiomi