Browse Source

Adds react-i18next and its provider to react.

Adds translate function with default namespaces and options.
master
damencho 8 years ago
parent
commit
e3d4152e32

+ 1
- 0
package.json View File

@@ -35,6 +35,7 @@
35 35
     "postis": "^2.2.0",
36 36
     "react": "15.4.2",
37 37
     "react-dom": "15.4.2",
38
+    "react-i18next": "2.2.0",
38 39
     "react-native": "0.41.2",
39 40
     "react-native-background-timer": "1.0.0",
40 41
     "react-native-immersive": "0.0.4",

+ 10
- 5
react/features/app/components/AbstractApp.js View File

@@ -5,6 +5,9 @@ import { Provider } from 'react-redux';
5 5
 import { compose, createStore } from 'redux';
6 6
 import Thunk from 'redux-thunk';
7 7
 
8
+import { I18nextProvider } from 'react-i18next';
9
+import { i18n } from '../../base/translation';
10
+
8 11
 import {
9 12
     localParticipantJoined,
10 13
     localParticipantLeft
@@ -134,11 +137,13 @@ export class AbstractApp extends Component {
134 137
 
135 138
         if (route) {
136 139
             return (
137
-                <Provider store = { this._getStore() }>
138
-                    {
139
-                        this._createElement(route.component)
140
-                    }
141
-                </Provider>
140
+                <I18nextProvider i18n = { i18n }>
141
+                    <Provider store = { this._getStore() }>
142
+                        {
143
+                            this._createElement(route.component)
144
+                        }
145
+                    </Provider>
146
+                </I18nextProvider>
142 147
             );
143 148
         }
144 149
 

+ 12
- 0
react/features/base/translation/functions.js View File

@@ -0,0 +1,12 @@
1
+import { translate as reactTranslate } from 'react-i18next';
2
+
3
+/**
4
+ * Wrap a translatable component.
5
+ *
6
+ * @param {Component} component - the component to wrap
7
+ * @returns {Component} the wrapped component.
8
+ */
9
+export function translate(component) {
10
+    // use the default list of namespaces
11
+    return reactTranslate([ 'main', 'languages' ], { wait: true })(component);
12
+}

+ 1
- 0
react/features/base/translation/index.js View File

@@ -1,2 +1,3 @@
1 1
 export { default as i18n } from './Translation';
2 2
 export * from './constants';
3
+export * from './functions';

Loading…
Cancel
Save