npm i --save i18nh
- 版本:0.0.5
- GitHub: https://github.com/rodrigooler/i18nh
- NPM: https://npmjs.net.cn/package/i18nh
- 下载
- 昨日: 0
- 上周: 0
- 上月: 0
安装
支持
- [x] NodeJS
- [x] React
- [x] NextJS
- [x] Create React App 1.0
- [x] Create React App 2.0
- [x] React Native
- [x] PhoneGap / Cordova
- [x] Angular
- [x] Vue
- [x] NativeScript
NPM
npm install i18nh --save
YARN
yarn add i18nh
使用
使用它很简单,只需查看以下步骤
import i18nh, { useT } from 'i18nh'
// Create a language object containing the
// translations as in the example below
const languages = {
en: {
hello: 'Hello',
about: 'About',
goodMorning: 'Good Morning',
},
pt: {
hello: 'Olá',
about: 'Sobre',
goodMorning: 'Bom Dia',
},
}
// i18nh load the language object containing
// the translations and also the default language argument
i18nh({
languages,
defaultLanguage: 'en'
});
const [t] = useT();
console.log(t('hello'))
// Hello
console.log(t('about'))
// About
console.log(t('goodMorning'))
// Good Morning
console.log(t('hello', 'pt'))
// Olá
console.log(t('about', 'pt'))
// Sobre
console.log(t('goodMorning', 'pt'))
// Bom Dia