Skip to content

Latest commit

 

History

History

use.i18n

@rcp/use.i18n

NPM version NPM Downloads

A react hook for using i18n

Installation

npm install @rcp/use.i18n
# or use yarn
yarn add @rcp/use.i18n

Usage

import useI18n from '@rcp/use.i18n'

function App({ locale = {}, language = 'zh' } = {}) {
  const { i18n } = useI18n(
    {
      zh: {
        title: '标题',
        content: '${1}, 内容'
      },
      en: {
        title: 'Title',
        content: '${1}, Content'
      }
    },
    { locale, language }
  )

  return <p>{i18n('content', i18n('title'))}</p>
}

API

Related

Authors

This library is written and maintained by imcuttle, <a href="mailto:[email protected]""[email protected]>.

License

MIT