A react hook for using i18n
npm install @rcp/use.i18n
# or use yarn
yarn add @rcp/use.i18n
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>
}
This library is written and maintained by imcuttle, <a href="mailto:[email protected]""[email protected]>.
MIT