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
     "postis": "^2.2.0",
35
     "postis": "^2.2.0",
36
     "react": "15.4.2",
36
     "react": "15.4.2",
37
     "react-dom": "15.4.2",
37
     "react-dom": "15.4.2",
38
+    "react-i18next": "2.2.0",
38
     "react-native": "0.41.2",
39
     "react-native": "0.41.2",
39
     "react-native-background-timer": "1.0.0",
40
     "react-native-background-timer": "1.0.0",
40
     "react-native-immersive": "0.0.4",
41
     "react-native-immersive": "0.0.4",

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

5
 import { compose, createStore } from 'redux';
5
 import { compose, createStore } from 'redux';
6
 import Thunk from 'redux-thunk';
6
 import Thunk from 'redux-thunk';
7
 
7
 
8
+import { I18nextProvider } from 'react-i18next';
9
+import { i18n } from '../../base/translation';
10
+
8
 import {
11
 import {
9
     localParticipantJoined,
12
     localParticipantJoined,
10
     localParticipantLeft
13
     localParticipantLeft
134
 
137
 
135
         if (route) {
138
         if (route) {
136
             return (
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

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
 export { default as i18n } from './Translation';
1
 export { default as i18n } from './Translation';
2
 export * from './constants';
2
 export * from './constants';
3
+export * from './functions';

Loading…
Cancel
Save