@dokuhero/react-18n-ts-helper
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

React i18n Typescript Helper

Set of helpers to work with react-i18next in Typescript.

Installation

Using npm:

npm i -S @dokuhero/react-18n-ts-helper

or yarn:

yarn add @dokuhero/react-18n-ts-helper

Usage

Translate HOC

import { withLocale } from '@dokuhero/react-18n-ts-helper'

interface TheComponentProps {
  // ... your props
}

const TheComponent = withLocale<TheComponentProps>('namespace')(({ t }) => (
  <div>{t('say-hello')}</div>
))

Translate Class Decorator

import { withLocaleClass, WithLocaleProps } from '@dokuhero/react-18n-ts-helper'

interface TheComponentProps extends WithLocaleProps {
  // ... your props
}

@withLocaleClass('common')
class TheComponent extends React.Component<TheComponentProps> {
  render() {
    const { t } = this.props
    return <div>{t('say-hello')}</div>
  }
}

License

MIT

/@dokuhero/react-18n-ts-helper/

    Package Sidebar

    Install

    npm i @dokuhero/react-18n-ts-helper

    Weekly Downloads

    0

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    4.05 kB

    Total Files

    5

    Last publish

    Collaborators

    • budiadiono