@spl-soft-react/language
v0.0.102
Published
i18n for react
Downloads
1
Readme
i18n
Internationalization (I18N) for reactJs
Installation
npm install @spl-soft-react/language --save
Usage
copy message
folder to project/src
Wrap your app with LanguageProvider
import { LanguageProvider } from '@spl-soft-react/language';
import messages from 'project/src/messages'
<LanguageProvider message={messages}>
<App />
</LanguageProvider>
import { withI18n } from '@spl-soft-react/language';
class Example extends React.Component {
render() {
const { t, setlanguagecode } = this.props;
return (
<div >
<h1>{t("hello")}</h1>
<p>{t('update {module-name}', {'module-name': t('product')})}</p>
<button onClick={()=>setlanguagecode('en')}>English</button>
<button onClick={()=>setlanguagecode('my')}>Myanmar</button>
<button onClick={()=>setlanguagecode('zg')}>Myanmar Zawgyi</button>
</div>
);
}
}
export default withi18n(Example);