Adds react-i18next and its provider to react.
Adds translate function with default namespaces and options.
This commit is contained in:
parent
d861ba1876
commit
e3d4152e32
|
@ -35,6 +35,7 @@
|
|||
"postis": "^2.2.0",
|
||||
"react": "15.4.2",
|
||||
"react-dom": "15.4.2",
|
||||
"react-i18next": "2.2.0",
|
||||
"react-native": "0.41.2",
|
||||
"react-native-background-timer": "1.0.0",
|
||||
"react-native-immersive": "0.0.4",
|
||||
|
|
|
@ -5,6 +5,9 @@ import { Provider } from 'react-redux';
|
|||
import { compose, createStore } from 'redux';
|
||||
import Thunk from 'redux-thunk';
|
||||
|
||||
import { I18nextProvider } from 'react-i18next';
|
||||
import { i18n } from '../../base/translation';
|
||||
|
||||
import {
|
||||
localParticipantJoined,
|
||||
localParticipantLeft
|
||||
|
@ -134,11 +137,13 @@ export class AbstractApp extends Component {
|
|||
|
||||
if (route) {
|
||||
return (
|
||||
<I18nextProvider i18n = { i18n }>
|
||||
<Provider store = { this._getStore() }>
|
||||
{
|
||||
this._createElement(route.component)
|
||||
}
|
||||
</Provider>
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import { translate as reactTranslate } from 'react-i18next';
|
||||
|
||||
/**
|
||||
* Wrap a translatable component.
|
||||
*
|
||||
* @param {Component} component - the component to wrap
|
||||
* @returns {Component} the wrapped component.
|
||||
*/
|
||||
export function translate(component) {
|
||||
// use the default list of namespaces
|
||||
return reactTranslate([ 'main', 'languages' ], { wait: true })(component);
|
||||
}
|
|
@ -1,2 +1,3 @@
|
|||
export { default as i18n } from './Translation';
|
||||
export * from './constants';
|
||||
export * from './functions';
|
||||
|
|
Loading…
Reference in New Issue