0.3.3 • Published 6 years ago

ndla-i18n v0.3.3

Weekly downloads
2
License
GPL-3.0
Repository
github
Last release
6 years ago

ndla-i18n

NDLA's own i18n package based on react-intl

Installation

# Using npm:
$ npm install ndla-i18n --save

# Using yarn:
$ yarn add ndla-i18n

Usage

// In app/server entry index file:
import IntlProvider from 'ndla-i18n';
...
ReactDOM.render(
  ...
    <IntlProvider locale="NB" messages={messages}>
      ...
    </IntlProvider>
  ...
  document.getElementById('root'),
);
// After initial instantiation, using it with a React component
...
import { injectT } from 'ndla-i18n';

class i18nReactComponent extends Component {
  ...
  render() {
    const { t } = this.props;
    return <button>{t('translationItem.buttonText')}</button>;
  }
}
...

export default injectT(i18nReactComponent);
// Using it with a render props component
...
import { Trans } from 'ndla-i18n';

class i18nReactComponent extends Component {
  ...
  render() {
    return(
      <Trans>
      {({ t }) => (<button>{t('translationItem.buttonText')}</button>)}
      </Trans>
    )
  }
}
...

export default i18nReactComponent;
0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago