浏览代码

ref(i18next): Remove the base/config dependancy.

master
hristoterezov 7 年前
父节点
当前提交
9131d2448d
共有 3 个文件被更改,包括 14 次插入66 次删除
  1. 14
    14
      modules/translation/translation.js
  2. 0
    2
      react/features/base/i18n/index.js
  3. 0
    50
      react/features/base/i18n/middleware.js

+ 14
- 14
modules/translation/translation.js 查看文件

@@ -23,20 +23,7 @@ class Translation {
23 23
     /**
24 24
      *
25 25
      */
26
-    generateTranslationHTML(key: string, options: Object) {
27
-        const optAttr
28
-            = options ? ` data-i18n-options='${JSON.stringify(options)}'` : '';
29
-
30
-        // XXX i18next expects undefined if options are missing.
31
-        const text = i18next.t(key, options ? options : undefined);
32
-
33
-        return `<span data-i18n="${key}"${optAttr}>${text}</span>`;
34
-    }
35
-
36
-    /**
37
-     *
38
-     */
39
-    init() {
26
+    constructor() {
40 27
         jqueryI18next.init(i18next, $, { useOptionsAttr: true });
41 28
 
42 29
         if (i18next.isInitialized) {
@@ -48,6 +35,19 @@ class Translation {
48 35
         i18next.on('languageChanged', _onI18nInitialized);
49 36
     }
50 37
 
38
+    /**
39
+     *
40
+     */
41
+    generateTranslationHTML(key: string, options: Object) {
42
+        const optAttr
43
+            = options ? ` data-i18n-options='${JSON.stringify(options)}'` : '';
44
+
45
+        // XXX i18next expects undefined if options are missing.
46
+        const text = i18next.t(key, options ? options : undefined);
47
+
48
+        return `<span data-i18n="${key}"${optAttr}>${text}</span>`;
49
+    }
50
+
51 51
     /**
52 52
      *
53 53
      */

+ 0
- 2
react/features/base/i18n/index.js 查看文件

@@ -4,5 +4,3 @@ export * from './functions';
4 4
 // TODO Eventually (e.g. when the non-React Web app is rewritten into React), it
5 5
 // should not be necessary to export i18next.
6 6
 export { default as i18next, DEFAULT_LANGUAGE, LANGUAGES } from './i18next';
7
-
8
-import './middleware';

+ 0
- 50
react/features/base/i18n/middleware.js 查看文件

@@ -1,50 +0,0 @@
1
-/* @flow */
2
-// FIXME: Using '../config/actionTypes' instead of '../config' is a quick fix
3
-// for the dial-in info page. Importing '../config' results in JitsiMeetJS
4
-// undefined error (/base/config imports /app which import /lib-jitsi-meet/).
5
-import { SET_CONFIG } from '../config/actionTypes';
6
-import { MiddlewareRegistry } from '../redux';
7
-
8
-declare var APP: Object;
9
-
10
-/**
11
- * The redux middleware of the feature base/i18n.
12
- *
13
- * @param {Store} store - The redux store.
14
- * @returns {Function}
15
- * @private
16
- */
17
-MiddlewareRegistry.register(store => next => action => {
18
-    switch (action.type) {
19
-    case SET_CONFIG:
20
-        return _setConfig(store, next, action);
21
-    }
22
-
23
-    return next(action);
24
-});
25
-
26
-/**
27
- * Notifies the feature base/i18n that the action SET_CONFIG is being dispatched
28
- * within a specific redux store.
29
- *
30
- * @param {Store} store - The redux store in which the specified action is being
31
- * dispatched.
32
- * @param {Dispatch} next - The redux dispatch function to dispatch the
33
- * specified action to the specified store.
34
- * @param {Action} action - The redux action SET_CONFIG which is being
35
- * dispatched in the specified store.
36
- * @private
37
- * @returns {Object} The new state that is the result of the reduction of the
38
- * specified action.
39
- */
40
-function _setConfig({ getState }, next, action) {
41
-    const oldValue = getState()['features/base/config'];
42
-    const result = next(action);
43
-    const newValue = getState()['features/base/config'];
44
-
45
-    if (oldValue !== newValue && typeof APP === 'object') {
46
-        APP.translation.init();
47
-    }
48
-
49
-    return result;
50
-}

正在加载...
取消
保存