kjl-i18n
v0.0.2
Published
国际化方案
Downloads
5
Readme
前端国际化方案
1. 开始
// index.js
import React from 'react';
import ReactDOM from 'react-dom';
import kjlI18n from 'kjl-i18n';
import en from './locales/en/translation.json';
import cn from './locales/cn/translation.json';
import App from './App';
const i18n = new kjlI18n(cn, en);
const I18nProvider = i18n.i18nProvider;
ReactDOM.render(
<I18nProvider i18n={i18n}>
<App />
</I18nProvider>,
document.getElementById('root')
);
// App.js
import React, { Component } from 'react';
import { t } from 'kjl-i18n';
class App extends React.Component {
render() {
return (
<div>
{t('词条翻译')}
</div>
)
}
}