@choffmeister/i18next
TypeScript icon, indicating that this package has built-in type declarations

0.3.3 • Public • Published

i18next

// .babelrc
{
  "plugins": [
    "module:@choffmeister/i18next"
  ]
}
// init.ts
import * as i18next from 'i18next'
import * as reactI18next from 'react-i18next'
import * as choffmeisterI18next from '@choffmeister/i18next'

i18next
  .use(reactI18next.initReactI18next)
  .use(choffmeisterI18next.init)
  .init(
    {
      fallbackLng: 'en',
      resources: {},
      interpolation: {
        escapeValue: false,
      },
      react: {
        wait: false,
        nsMode: 'default',
      },
      debug: process.env.NODE_ENV !== 'production',
    },
    err => {
      if (err) {
        // tslint:disable-next-line no-console
        console.error(err)
      }
    }
  )
// Greeting.ts
import * as React from 'react'
import { createTranslation } from '@choffmeister/i18next'

interface Props {
  name: string
}

export const Greeting: React.FunctionComponent<Props> = ({ name }) => {
  const { t } = useTranslation()
  return (
    <div>
      {t('greeting', { name })}
    </div>
  )
}

const { useTranslation } = createTranslation({
  greeting: {
    en: 'Hello, {{name}}!',
    de: 'Hallo, {{name}}!'
  }
})

/@choffmeister/i18next/

    Package Sidebar

    Install

    npm i @choffmeister/i18next

    Weekly Downloads

    80

    Version

    0.3.3

    License

    MIT

    Unpacked Size

    11.4 kB

    Total Files

    22

    Last publish

    Collaborators

    • choffmeister