@bradtech/translations
v2.8.12
Published
Translations and Translators for Brad apps
Downloads
232
Readme
Translations
install
with npm
$ npm install @bradtech/translations
with yarn
$ yarn add @bradtech/translations
Example
in index.js
import App from './App'
import { i18n, I18nextProvider } from '@bradtech/translations'
const load = () => {
;<I18nextProvider i18n={i18n}>
<App />
</I18nextProvider>
}
in App.js
import React from 'react'
import { compose } from 'recompose'
import { withTranslation } from 'react-i18next'
const App = props => {
const { t } = this.props
// we get our translation function in the props
return (
<div>
<p>{t('home.welcome')}</p>
</div>
)
}
export default compose(withTranslation)(App)
in Cloud functions
import { i18n } from '@bradtech/translations'
i18n.init({
lng: user.get('lang') || 'fr',
})