1.0.1 • Published 5 years ago

inno-trans-react-plugin v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

inno-trans-react-plugin

A inno-trans plugin for react.

npm

Install

npm i inno-trans-react-plugin

Example

const InnoTrans = require('inno-trans');
const InnoTransReactPlugin = require('inno-trans-react-plugin');

const trans = InnoTrans({
    locale: 'en',
    message: {
        en: {
            'hello': 'hello!'
        },
        ko: {
            'hello': '안녕!'
        }
    },
    plugins: [InnoTransReactPlugin] // 1. Add a plugin.
})

function App(){
    const {t} = trans.useT() // 2. You can now use the `useT()` hook.

    return <span>{ t('hello') }</span> // => "<span>hello</span>"
}

trans.locale('ko') // App rerenders like "<span>안녕!</span>"

Related

  • inno-trans - 📜 simple localization library (inspired by laravel translation)

License

MIT