tinytranslate

2.0.0 • Public • Published

TinyTranslate

A tiny hook to manage translations in your React Application

MIT license node workflow

Features

  1. Support for deeply nested objects. Eg: translate('profile.top.heading')
  2. 100% Test coverage
  3. Fully controlled and stateless

Install

yarn add tinytranslate

OR

npm i tinytranslate --save

Usage

  1. Define your translations
const translations = {
  en: {
    locale: 'en-US',
    messages: {
      hello: 'Hello {name}'
    }
  },
}
  1. Add TranslationProvider to your app
import { TranslationProvider } from 'tinytranslate'

const App = () => {
  return (
    <TranslationProvider translations={translations} locale='en'>
      <Header />
    </TranslationProvider>
  )
}

  1. Use useTranslation hook
import { useTranslation } from 'tinytranslate'

const Header = () => {
  const translate = useTranslation()

  return <>{translate('hello'}</>
}

Readme

Keywords

none

Package Sidebar

Install

npm i tinytranslate

Weekly Downloads

3

Version

2.0.0

License

MIT

Unpacked Size

19.9 kB

Total Files

28

Last publish

Collaborators

  • rmdort