Pārlūkot izejas kodu

Comply w/ coding style

j8
Lyubo Marinov 8 gadus atpakaļ
vecāks
revīzija
18368fefaa
32 mainītis faili ar 397 papildinājumiem un 295 dzēšanām
  1. 7
    1
      .jshintignore
  2. 25
    27
      lang/main.json
  3. 3
    2
      modules/UI/side_pannels/settings/SettingsMenu.js
  4. 38
    28
      modules/translation/translation.js
  5. 1
    1
      package.json
  6. 3
    4
      react/features/app/components/AbstractApp.js
  7. 10
    6
      react/features/base/i18n/configLanguageDetector.js
  8. 36
    0
      react/features/base/i18n/constants.js
  9. 31
    0
      react/features/base/i18n/functions.js
  10. 63
    0
      react/features/base/i18n/i18next.js
  11. 6
    0
      react/features/base/i18n/index.js
  12. 24
    0
      react/features/base/i18n/languageDetector.native.js
  13. 42
    0
      react/features/base/i18n/languageDetector.web.js
  14. 5
    4
      react/features/base/react/components/Watermarks.web.js
  15. 1
    1
      react/features/base/react/components/index.js
  16. 0
    11
      react/features/base/translation/LanguageDetector.native.js
  17. 0
    34
      react/features/base/translation/LanguageDetector.web.js
  18. 0
    46
      react/features/base/translation/Translation.js
  19. 0
    13
      react/features/base/translation/constants.js
  20. 0
    32
      react/features/base/translation/functions.js
  21. 0
    3
      react/features/base/translation/index.js
  22. 8
    2
      react/features/conference/components/PasswordRequiredPrompt.native.js
  23. 1
    2
      react/features/overlay/components/PageReloadOverlay.js
  24. 3
    3
      react/features/overlay/components/ReloadTimer.js
  25. 2
    2
      react/features/overlay/components/SuspendedOverlay.js
  26. 13
    7
      react/features/overlay/components/UserMediaPermissionsOverlay.js
  27. 9
    2
      react/features/room-lock/components/RoomLockPrompt.native.js
  28. 15
    9
      react/features/unsupported-browser/components/UnsupportedDesktopBrowser.js
  29. 44
    17
      react/features/unsupported-browser/components/UnsupportedMobileBrowser.js
  30. 1
    2
      react/features/welcome/components/WelcomePage.native.js
  31. 6
    9
      react/features/welcome/components/WelcomePage.web.js
  32. 0
    27
      service/translation/languages.js

+ 7
- 1
.jshintignore Parādīt failu

@@ -5,8 +5,14 @@ debian/
5 5
 libs/
6 6
 node_modules/
7 7
 
8
-# The following are checked by ESLint which supersedes JSHint.
8
+# The following are checked by ESLint with the maximum configuration which
9
+# supersedes JSHint.
9 10
 flow-typed/
10 11
 react/
11 12
 
13
+# The following are checked by ESLint with the minimum configuration which does
14
+# not supersede JSHint but take advantage of advanced language features such as
15
+# Facebook Flow which are not supported by JSHint.
16
+modules/translation/translation.js
17
+
12 18
 analytics.js

+ 25
- 27
lang/main.json Parādīt failu

@@ -39,44 +39,44 @@
39 39
         "videoMute": "Start or stop your camera"
40 40
     },
41 41
     "welcomepage":{
42
-        "go": "GO",
43
-        "join": "JOIN",
44
-        "roomname": "Enter room name",
45
-        "roomnamePlaceHolder": "room name",
46 42
         "disable": "Don't show this page again",
47 43
         "feature1": {
48
-            "title": "Simple to use",
49
-            "content": "No downloads required. __app__ works directly within your browser. Simply share your conference URL with others to get started."
44
+            "content": "No downloads required. __app__ works directly within your browser. Simply share your conference URL with others to get started.",
45
+            "title": "Simple to use"
50 46
         },
51 47
         "feature2": {
52
-            "title": "Low bandwidth",
53
-            "content": "Multi-party video conferences work with as little as 128Kbps. Screen-sharing and audio-only conferences are possible with far less."
48
+            "content": "Multi-party video conferences work with as little as 128Kbps. Screen-sharing and audio-only conferences are possible with far less.",
49
+            "title": "Low bandwidth"
54 50
         },
55 51
         "feature3": {
56
-            "title": "Open source",
57
-            "content": "__app__ is licensed under the Apache License. You are free to download, use, modify, and share it as per this license."
52
+            "content": "__app__ is licensed under the Apache License. You are free to download, use, modify, and share it as per this license.",
53
+            "title": "Open source"
58 54
         },
59 55
         "feature4": {
60
-            "title": "Unlimited users",
61
-            "content": "There are no artificial restrictions on the number of users or conference participants. Server power and bandwidth are the only limiting factors."
56
+            "content": "There are no artificial restrictions on the number of users or conference participants. Server power and bandwidth are the only limiting factors.",
57
+            "title": "Unlimited users"
62 58
         },
63 59
         "feature5": {
64
-            "title": "Screen sharing",
65
-            "content": "It's easy to share your screen with others. __app__ is ideal for on-line presentations, lectures, and tech support sessions."
60
+            "content": "It's easy to share your screen with others. __app__ is ideal for on-line presentations, lectures, and tech support sessions.",
61
+            "title": "Screen sharing"
66 62
         },
67 63
         "feature6": {
68
-            "title": "Secure rooms",
69
-            "content": "Need some privacy? __app__ conference rooms can be secured with a password in order to exclude unwanted guests and prevent interruptions."
64
+            "content": "Need some privacy? __app__ conference rooms can be secured with a password in order to exclude unwanted guests and prevent interruptions.",
65
+            "title": "Secure rooms"
70 66
         },
71 67
         "feature7": {
72
-            "title": "Shared notes",
73
-            "content": "__app__ features Etherpad, a real-time collaborative text editor that's great for meeting minutes, writing articles, and more."
68
+            "content": "__app__ features Etherpad, a real-time collaborative text editor that's great for meeting minutes, writing articles, and more.",
69
+            "title": "Shared notes"
74 70
         },
75 71
         "feature8": {
76
-            "title": "Usage statistics",
77
-            "content": "Learn about your users through easy integration with Piwik, Google Analytics, and other usage monitoring and statistics systems."
72
+            "content": "Learn about your users through easy integration with Piwik, Google Analytics, and other usage monitoring and statistics systems.",
73
+            "title": "Usage statistics"
78 74
         },
75
+        "go": "GO",
76
+        "join": "JOIN",
79 77
         "privacy": "Privacy",
78
+        "roomname": "Enter room name",
79
+        "roomnamePlaceHolder": "room name",
80 80
         "sendFeedback": "Send feedback",
81 81
         "terms": "Terms"
82 82
     },
@@ -115,14 +115,12 @@
115 115
         "profile": "Edit your profile",
116 116
         "raiseHand": "Raise / Lower your hand"
117 117
     },
118
-    "unsupportedPage": {
119
-        "onlySupportedBy": "This application is currently only supported by",
120
-        "download": "DOWNLOAD",
121
-        "joinConversation": "Join the conversation",
122
-        "startConference": "Start a conference",
123
-        "joinConversationMobile": "You need <strong>__app__</strong> to join a conversation on your mobile",
118
+    "unsupportedBrowser": {
119
+        "appInstalled": "or if you already have it<br /><strong>then</strong>",
120
+        "appNotInstalled": "You need <strong>__app__</strong> to join a conversation on your mobile",
124 121
         "downloadApp": "Download the App",
125
-        "availableApp": "or if you already have it<br /><strong>then</strong>"
122
+        "joinConversation": "Join the conversation",
123
+        "startConference": "Start a conference"
126 124
     },
127 125
     "bottomtoolbar": {
128 126
         "chat": "Open / close chat",

+ 3
- 2
modules/UI/side_pannels/settings/SettingsMenu.js Parādīt failu

@@ -1,8 +1,9 @@
1 1
 /* global $, APP, AJS, interfaceConfig, JitsiMeetJS */
2 2
 
3
+import { LANGUAGES } from "../../../../react/features/base/i18n";
4
+
3 5
 import UIUtil from "../../util/UIUtil";
4 6
 import UIEvents from "../../../../service/UI/UIEvents";
5
-import languages from "../../../../service/translation/languages";
6 7
 import Settings from '../../../settings/Settings';
7 8
 
8 9
 const sidePanelsContainerId = 'sideToolbarContainer';
@@ -145,7 +146,7 @@ export default {
145 146
             let selectInput;
146 147
 
147 148
             selectEl.html(generateLanguagesOptions(
148
-                languages.getLanguages(),
149
+                LANGUAGES,
149 150
                 APP.translation.getCurrentLanguage()
150 151
             ));
151 152
             initSelect2(selectEl, () => {

+ 38
- 28
modules/translation/translation.js Parādīt failu

@@ -1,46 +1,56 @@
1
-/* global $ */
2
-import { i18n, DEFAULT_LANG } from '../../react/features/base/translation';
1
+/* @flow */
2
+
3 3
 import jqueryI18next from 'jquery-i18next';
4 4
 
5
-function initCompleted() {
6
-    $("[data-i18n]").localize();
5
+import { DEFAULT_LANGUAGE, i18next } from '../../react/features/base/i18n';
6
+
7
+declare var $: Function;
8
+
9
+/**
10
+ * Notifies that the {@link i18next} instance has finished its initialization.
11
+ *
12
+ * @returns {void}
13
+ * @private
14
+ */
15
+function _onI18nInitialized() {
16
+    $('[data-i18n]').localize();
7 17
 }
8 18
 
9 19
 class Translation {
10
-    init () {
11
-        if (i18n.isInitialized)
12
-            initCompleted();
13
-        else
14
-            i18n.on('initialized', initCompleted);
15
-
16
-        jqueryI18next.init(i18n, $, {useOptionsAttr: true});
20
+    addLanguageChangedListener(listener: Function) {
21
+        i18next.on('languageChanged', listener);
17 22
     }
18 23
 
19
-    setLanguage (lang) {
20
-        if(!lang)
21
-            lang = DEFAULT_LANG;
22
-        i18n.setLng(lang, {}, initCompleted);
24
+    generateTranslationHTML(key: string, options: Object) {
25
+        const optAttr
26
+            = options ? ` data-i18n-options='${JSON.stringify(options)}'` : '';
27
+
28
+        // XXX i18next expects undefined if options are missing.
29
+        const text = i18next.t(key, options ? options : undefined);
30
+
31
+        return `<span data-i18n="${key}"${optAttr}>${text}</span>`;
23 32
     }
24 33
 
25
-    getCurrentLanguage () {
26
-        return i18n.lng();
34
+    getCurrentLanguage() {
35
+        return i18next.lng();
27 36
     }
28 37
 
29
-    translateElement (selector, options) {
30
-        // i18next expects undefined if options are missing, check if its null
31
-        selector.localize(
32
-            options === null ? undefined : options);
38
+    init() {
39
+        if (i18next.isInitialized)
40
+            _onI18nInitialized();
41
+        else
42
+            i18next.on('initialized', _onI18nInitialized);
43
+
44
+        jqueryI18next.init(i18next, $, { useOptionsAttr: true });
33 45
     }
34 46
 
35
-    generateTranslationHTML (key, options) {
36
-        let optAttr = options
37
-            ? ` data-i18n-options='${JSON.stringify(options)}'` : "";
38
-        let text = i18n.t(key, options === null ? undefined : options);
39
-        return `<span data-i18n="${key}"${optAttr}>${text}</span>`;
47
+    setLanguage(language: string = DEFAULT_LANGUAGE) {
48
+        i18next.setLng(language, {}, _onI18nInitialized);
40 49
     }
41 50
 
42
-    addLanguageChangedListener(listener) {
43
-        i18n.on('languageChanged', listener);
51
+    translateElement(selector: Object, options: Object) {
52
+        // XXX i18next expects undefined if options are missing.
53
+        selector.localize(options ? options : undefined);
44 54
     }
45 55
 }
46 56
 

+ 1
- 1
package.json Parādīt failu

@@ -40,7 +40,7 @@
40 40
     "react-native-background-timer": "1.0.0",
41 41
     "react-native-immersive": "0.0.4",
42 42
     "react-native-keep-awake": "^2.0.2",
43
-    "react-native-locale-detector": "1.0.1 ",
43
+    "react-native-locale-detector": "1.0.1",
44 44
     "react-native-prompt": "^1.0.0",
45 45
     "react-native-vector-icons": "^4.0.0",
46 46
     "react-native-webrtc": "jitsi/react-native-webrtc",

+ 3
- 4
react/features/app/components/AbstractApp.js Parādīt failu

@@ -1,13 +1,12 @@
1 1
 /* global APP */
2 2
 
3 3
 import React, { Component } from 'react';
4
+import { I18nextProvider } from 'react-i18next';
4 5
 import { Provider } from 'react-redux';
5 6
 import { compose, createStore } from 'redux';
6 7
 import Thunk from 'redux-thunk';
7 8
 
8
-import { I18nextProvider } from 'react-i18next';
9
-import { i18n } from '../../base/translation';
10
-
9
+import { i18next } from '../../base/i18n';
11 10
 import {
12 11
     localParticipantJoined,
13 12
     localParticipantLeft
@@ -137,7 +136,7 @@ export class AbstractApp extends Component {
137 136
 
138 137
         if (route) {
139 138
             return (
140
-                <I18nextProvider i18n = { i18n }>
139
+                <I18nextProvider i18n = { i18next }>
141 140
                     <Provider store = { this._getStore() }>
142 141
                         {
143 142
                             this._createElement(route.component)

react/features/base/translation/ConfigLanguageDetector.js → react/features/base/i18n/configLanguageDetector.js Parādīt failu

@@ -1,16 +1,20 @@
1
-/* global config */
1
+/* @flow */
2
+
3
+declare var config: Object;
2 4
 
3 5
 /**
4 6
  * Custom language detection, just returns the config property if any.
5 7
  */
6 8
 export default {
7 9
     /**
8
-     * Name of the language detector.
10
+     * Does not support caching.
11
+     *
12
+     * @returns {void}
9 13
      */
10
-    name: 'configLanguageDetector',
14
+    cacheUserLanguage: Function.prototype,
11 15
 
12 16
     /**
13
-     * The actual lookup.
17
+     * Looks the language up in the config.
14 18
      *
15 19
      * @returns {string} The default language if any.
16 20
      */
@@ -19,7 +23,7 @@ export default {
19 23
     },
20 24
 
21 25
     /**
22
-     * Doesn't support caching.
26
+     * Name of the language detector.
23 27
      */
24
-    cacheUserLanguage: Function.prototype
28
+    name: 'configLanguageDetector'
25 29
 };

+ 36
- 0
react/features/base/i18n/constants.js Parādīt failu

@@ -0,0 +1,36 @@
1
+/**
2
+ * The available/supported languages.
3
+ *
4
+ * XXX The element at index zero is the default language.
5
+ *
6
+ * @public
7
+ * @type {Array<string>}
8
+ */
9
+export const LANGUAGES = [
10
+    'en', // XXX The default language.
11
+
12
+    'bg',
13
+    'de',
14
+    'es',
15
+    'fr',
16
+    'hy',
17
+    'it',
18
+    'oc',
19
+    'pl',
20
+    'ptBR',
21
+    'ru',
22
+    'sk',
23
+    'sl',
24
+    'sv',
25
+    'tr'
26
+];
27
+
28
+/**
29
+ * The default language.
30
+ *
31
+ * XXX The element at index zero of {@link LANGUAGES} is the default language.
32
+ *
33
+ * @public
34
+ * @type {string} The default language.
35
+ */
36
+export const DEFAULT_LANGUAGE = LANGUAGES[0];

+ 31
- 0
react/features/base/i18n/functions.js Parādīt failu

@@ -0,0 +1,31 @@
1
+import React from 'react';
2
+import { translate as reactI18nextTranslate } from 'react-i18next';
3
+
4
+/**
5
+ * Wraps a specific React Component in order to enable translations in it.
6
+ *
7
+ * @param {Component} component - The React Component to wrap.
8
+ * @returns {Component} The React Component which wraps {@link component} and
9
+ * enables translations in it.
10
+ */
11
+export function translate(component) {
12
+    // Use the default list of namespaces.
13
+    return (
14
+        reactI18nextTranslate([ 'main', 'languages' ], { wait: true })(
15
+                component));
16
+}
17
+
18
+/**
19
+ * Translates a specific key to text containing HTML via a specific translate
20
+ * function.
21
+ *
22
+ * @param {Function} t - The translate function.
23
+ * @param {string} key - The key to translate.
24
+ * @param {Array<*>} options - The options, if any, to pass to {@link t}.
25
+ * @returns {ReactElement} A ReactElement which depicts the translated HTML
26
+ * text.
27
+ */
28
+export function translateToHTML(t, key, options = {}) {
29
+    // eslint-disable-next-line react/no-danger
30
+    return <span dangerouslySetInnerHTML = {{ __html: t(key, options) }} />;
31
+}

+ 63
- 0
react/features/base/i18n/i18next.js Parādīt failu

@@ -0,0 +1,63 @@
1
+import i18next from 'i18next';
2
+import I18nextXHRBackend from 'i18next-xhr-backend';
3
+
4
+import LANGUAGES_RESOURCES from '../../../../lang/languages.json';
5
+import MAIN_RESOURCES from '../../../../lang/main.json';
6
+
7
+import { DEFAULT_LANGUAGE, LANGUAGES } from './constants';
8
+import languageDetector from './languageDetector';
9
+
10
+declare var interfaceConfig: Object;
11
+
12
+/**
13
+ * The options to initialize i18next with.
14
+ *
15
+ * @type {Object}
16
+ */
17
+const options = {
18
+    app:
19
+        (typeof interfaceConfig !== 'undefined' && interfaceConfig.APP_NAME)
20
+            || 'Jitsi Meet',
21
+    compatibilityAPI: 'v1',
22
+    compatibilityJSON: 'v1',
23
+    fallbackLng: DEFAULT_LANGUAGE,
24
+    fallbackOnEmpty: true,
25
+    fallbackOnNull: true,
26
+
27
+    // XXX i18next modifies the array lngWhitelist so make sure to clone
28
+    // LANGUAGES.
29
+    lngWhitelist: LANGUAGES.slice(),
30
+    load: 'unspecific',
31
+    ns: {
32
+        defaultNs: 'main',
33
+        namespaces: [ 'main', 'languages' ]
34
+    },
35
+    resGetPath: 'lang/__ns__-__lng__.json',
36
+    useDataAttrOptions: true
37
+};
38
+
39
+i18next
40
+    .use(I18nextXHRBackend)
41
+    .use(languageDetector)
42
+    .use({
43
+        name: 'resolveAppName',
44
+        process: (res, key) => i18next.t(key, { app: options.app }),
45
+        type: 'postProcessor'
46
+    })
47
+    .init(options);
48
+
49
+// Add default language which is preloaded from the source code.
50
+i18next.addResourceBundle(
51
+        DEFAULT_LANGUAGE,
52
+        'main',
53
+        MAIN_RESOURCES,
54
+        /* deep */ true,
55
+        /* overwrite */ true);
56
+i18next.addResourceBundle(
57
+        DEFAULT_LANGUAGE,
58
+        'languages',
59
+        LANGUAGES_RESOURCES,
60
+        /* deep */ true,
61
+        /* overwrite */ true);
62
+
63
+export default i18next;

+ 6
- 0
react/features/base/i18n/index.js Parādīt failu

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

+ 24
- 0
react/features/base/i18n/languageDetector.native.js Parādīt failu

@@ -0,0 +1,24 @@
1
+/* @flow */
2
+
3
+import locale from 'react-native-locale-detector';
4
+
5
+/**
6
+ * The singleton language detector for React Native which uses the system-wide
7
+ * locale.
8
+ */
9
+export default {
10
+    /**
11
+     * Does not support caching.
12
+     *
13
+     * @returns {void}
14
+     */
15
+    cacheUserLanguage: Function.prototype,
16
+
17
+    detect() {
18
+        return locale;
19
+    },
20
+
21
+    init: Function.prototype,
22
+
23
+    type: 'languageDetector'
24
+};

+ 42
- 0
react/features/base/i18n/languageDetector.web.js Parādīt failu

@@ -0,0 +1,42 @@
1
+/* @flow */
2
+
3
+import BrowserLanguageDetector from 'i18next-browser-languagedetector';
4
+
5
+import configLanguageDetector from './configLanguageDetector';
6
+
7
+declare var interfaceConfig: Object;
8
+
9
+/**
10
+ * The ordered list (by name) of language detectors to be utilized as backends
11
+ * by the singleton language detector for Web.
12
+ *
13
+ * @type {Array<string>}
14
+ */
15
+const order = [
16
+    'querystring',
17
+    'localStorage',
18
+    configLanguageDetector.name
19
+];
20
+
21
+// Allow i18next to detect the system language reported by the Web browser
22
+// itself.
23
+interfaceConfig.LANG_DETECTION && order.push('navigator');
24
+
25
+/**
26
+ * The singleton language detector for Web.
27
+ */
28
+const languageDetector
29
+    = new BrowserLanguageDetector(
30
+        /* services */ null,
31
+        /* options */ {
32
+            caches: [ 'localStorage' ],
33
+            lookupLocalStorage: 'language',
34
+            lookupQuerystring: 'lang',
35
+            order
36
+        });
37
+
38
+// Add the language detector which looks the language up in the config. Its
39
+// order has already been established above.
40
+languageDetector.addDetector(configLanguageDetector);
41
+
42
+export default languageDetector;

+ 5
- 4
react/features/base/react/components/Watermarks.web.js Parādīt failu

@@ -1,7 +1,8 @@
1 1
 /* @flow */
2 2
 
3 3
 import React, { Component } from 'react';
4
-import { translate } from '../../translation';
4
+
5
+import { translate } from '../../i18n';
5 6
 
6 7
 declare var APP: Object;
7 8
 declare var interfaceConfig: Object;
@@ -19,7 +20,7 @@ const _RIGHT_WATERMARK_STYLE = {
19 20
  * A Web Component which renders watermarks such as Jits, brand, powered by,
20 21
  * etc.
21 22
  */
22
-class WatermarksComponent extends Component {
23
+class Watermarks extends Component {
23 24
     state = {
24 25
         brandWatermarkLink: String,
25 26
         jitsiWatermarkLink: String,
@@ -147,7 +148,7 @@ class WatermarksComponent extends Component {
147 148
                     className = 'poweredby'
148 149
                     href = 'http://jitsi.org'
149 150
                     target = '_new'>
150
-                    <span>{t('poweredby')} jitsi.org</span>
151
+                    <span>{ t('poweredby') } jitsi.org</span>
151 152
                 </a>
152 153
             );
153 154
         }
@@ -156,4 +157,4 @@ class WatermarksComponent extends Component {
156 157
     }
157 158
 }
158 159
 
159
-export const Watermarks = translate(WatermarksComponent);
160
+export default translate(Watermarks);

+ 1
- 1
react/features/base/react/components/index.js Parādīt failu

@@ -1,3 +1,3 @@
1 1
 export * from './Container';
2 2
 export * from './Link';
3
-export * from './Watermarks';
3
+export { default as Watermarks } from './Watermarks';

+ 0
- 11
react/features/base/translation/LanguageDetector.native.js Parādīt failu

@@ -1,11 +0,0 @@
1
-import locale from 'react-native-locale-detector';
2
-
3
-/**
4
- * A language detector that uses native locale.
5
- */
6
-export default {
7
-    init: Function.prototype,
8
-    type: 'languageDetector',
9
-    detect: () => locale,
10
-    cacheUserLanguage: Function.prototype
11
-};

+ 0
- 34
react/features/base/translation/LanguageDetector.web.js Parādīt failu

@@ -1,34 +0,0 @@
1
-/* global interfaceConfig */
2
-import Browser from 'i18next-browser-languagedetector';
3
-import ConfigLanguageDetector from './ConfigLanguageDetector';
4
-
5
-/**
6
- * List of detectors to use in their order.
7
- *
8
- * @type {[*]}
9
- */
10
-const detectors = [ 'querystring', 'localStorage', 'configLanguageDetector' ];
11
-
12
-/**
13
- * Allow i18n to detect the system language from the browser.
14
- */
15
-if (interfaceConfig.LANG_DETECTION) {
16
-    detectors.push('navigator');
17
-}
18
-
19
-/**
20
- * The language detectors.
21
- */
22
-const browser = new Browser(null, {
23
-    order: detectors,
24
-    lookupQuerystring: 'lang',
25
-    lookupLocalStorage: 'language',
26
-    caches: [ 'localStorage' ]
27
-});
28
-
29
-/**
30
- * adds a language detector that just checks the config
31
- */
32
-browser.addDetector(ConfigLanguageDetector);
33
-
34
-export default browser;

+ 0
- 46
react/features/base/translation/Translation.js Parādīt failu

@@ -1,46 +0,0 @@
1
-/* global interfaceConfig */
2
-import i18n from 'i18next';
3
-import XHR from 'i18next-xhr-backend';
4
-import { DEFAULT_LANG, languages } from './constants';
5
-import languagesR from '../../../../lang/languages.json';
6
-import mainR from '../../../../lang/main.json';
7
-
8
-import LanguageDetector from './LanguageDetector';
9
-
10
-/**
11
- * Default options to initialize i18next.
12
- *
13
- * @enum {string}
14
- */
15
-const defaultOptions = {
16
-    compatibilityAPI: 'v1',
17
-    compatibilityJSON: 'v1',
18
-    fallbackLng: DEFAULT_LANG,
19
-    load: 'unspecific',
20
-    resGetPath: 'lang/__ns__-__lng__.json',
21
-    ns: {
22
-        namespaces: [ 'main', 'languages' ],
23
-        defaultNs: 'main'
24
-    },
25
-    lngWhitelist: languages.getLanguages(),
26
-    fallbackOnNull: true,
27
-    fallbackOnEmpty: true,
28
-    useDataAttrOptions: true,
29
-    app: typeof interfaceConfig === 'undefined'
30
-        ? 'Jitsi Meet' : interfaceConfig.APP_NAME
31
-};
32
-
33
-i18n.use(XHR)
34
-    .use(LanguageDetector)
35
-    .use({
36
-        type: 'postProcessor',
37
-        name: 'resolveAppName',
38
-        process: (res, key) => i18n.t(key, { app: defaultOptions.app })
39
-    })
40
-    .init(defaultOptions);
41
-
42
-// adds default language which is preloaded from code
43
-i18n.addResourceBundle(DEFAULT_LANG, 'main', mainR, true, true);
44
-i18n.addResourceBundle(DEFAULT_LANG, 'languages', languagesR, true, true);
45
-
46
-export default i18n;

+ 0
- 13
react/features/base/translation/constants.js Parādīt failu

@@ -1,13 +0,0 @@
1
-import languages from '../../../../service/translation/languages';
2
-
3
-/**
4
- * The default language globally for the project.
5
- *
6
- * @type {string} the default language globally for the project.
7
- */
8
-export const DEFAULT_LANG = languages.EN;
9
-
10
-/**
11
- * Exports the list of languages currently supported.
12
- */
13
-export { languages };

+ 0
- 32
react/features/base/translation/functions.js Parādīt failu

@@ -1,32 +0,0 @@
1
-import { translate as reactTranslate } from 'react-i18next';
2
-import React from 'react';
3
-
4
-/**
5
- * Wrap a translatable component.
6
- *
7
- * @param {Component} component - The component to wrap.
8
- * @returns {Component} The wrapped component.
9
- */
10
-export function translate(component) {
11
-    // use the default list of namespaces
12
-    return reactTranslate([ 'main', 'languages' ], { wait: true })(component);
13
-}
14
-
15
-/**
16
- * Translates key and prepares data to be passed to dangerouslySetInnerHTML.
17
- * Used when translation text contains html.
18
- *
19
- * @param {func} t - Translate function.
20
- * @param {string} key - The key to translate.
21
- * @param {Array} options - Optional options.
22
- * @returns {XML} A span using dangerouslySetInnerHTML to insert html text.
23
- */
24
-export function translateToHTML(t, key, options = {}) {
25
-    /* eslint-disable react/no-danger */
26
-    return (
27
-        <span
28
-            dangerouslySetInnerHTML = {{ __html: t(key, options) }} />
29
-    );
30
-
31
-    /* eslint-enable react/no-danger */
32
-}

+ 0
- 3
react/features/base/translation/index.js Parādīt failu

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

+ 8
- 2
react/features/conference/components/PasswordRequiredPrompt.native.js Parādīt failu

@@ -3,8 +3,7 @@ import Prompt from 'react-native-prompt';
3 3
 import { connect } from 'react-redux';
4 4
 
5 5
 import { setPassword } from '../../base/conference';
6
-
7
-import { translate } from '../../base/translation';
6
+import { translate } from '../../base/i18n';
8 7
 
9 8
 /**
10 9
  * Implements a React Component which prompts the user when a password is
@@ -24,6 +23,13 @@ class PasswordRequiredPrompt extends Component {
24 23
          */
25 24
         conference: React.PropTypes.object,
26 25
         dispatch: React.PropTypes.func,
26
+
27
+        /**
28
+         * The function to translate human-readable text.
29
+         *
30
+         * @public
31
+         * @type {Function}
32
+         */
27 33
         t: React.PropTypes.func
28 34
     }
29 35
 

+ 1
- 2
react/features/overlay/components/PageReloadOverlay.js Parādīt failu

@@ -1,12 +1,11 @@
1 1
 import React from 'react';
2 2
 
3
+import { translate } from '../../base/i18n';
3 4
 import { randomInt } from '../../base/util';
4 5
 
5 6
 import AbstractOverlay from './AbstractOverlay';
6 7
 import ReloadTimer from './ReloadTimer';
7 8
 
8
-import { translate } from '../../base/translation';
9
-
10 9
 declare var APP: Object;
11 10
 
12 11
 const logger = require('jitsi-meet-logger').getLogger(__filename);

+ 3
- 3
react/features/overlay/components/ReloadTimer.js Parādīt failu

@@ -1,6 +1,6 @@
1 1
 import React, { Component } from 'react';
2 2
 
3
-import { translate } from '../../base/translation';
3
+import { translate } from '../../base/i18n';
4 4
 
5 5
 declare var AJS: Object;
6 6
 
@@ -57,10 +57,10 @@ class ReloadTimer extends Component {
57 57
         step: React.PropTypes.number,
58 58
 
59 59
         /**
60
-         * The function used to translate strings.
60
+         * The function to translate human-readable text.
61 61
          *
62 62
          * @public
63
-         * @type {func}
63
+         * @type {Function}
64 64
          */
65 65
         t: React.PropTypes.func
66 66
     }

+ 2
- 2
react/features/overlay/components/SuspendedOverlay.js Parādīt failu

@@ -1,8 +1,8 @@
1 1
 import React from 'react';
2 2
 
3
-import AbstractOverlay from './AbstractOverlay';
3
+import { translate } from '../../base/i18n';
4 4
 
5
-import { translate } from '../../base/translation';
5
+import AbstractOverlay from './AbstractOverlay';
6 6
 
7 7
 /**
8 8
  * Implements a React Component for suspended overlay. Shown when a suspend is

+ 13
- 7
react/features/overlay/components/UserMediaPermissionsOverlay.js Parādīt failu

@@ -2,9 +2,9 @@
2 2
 
3 3
 import React from 'react';
4 4
 
5
-import AbstractOverlay from './AbstractOverlay';
5
+import { translate, translateToHTML } from '../../base/i18n';
6 6
 
7
-import { translate, translateToHTML } from '../../base/translation';
7
+import AbstractOverlay from './AbstractOverlay';
8 8
 
9 9
 /**
10 10
  * Implements a React Component for overlay with guidance how to proceed with
@@ -56,7 +56,7 @@ class UserMediaPermissionsOverlay extends AbstractOverlay {
56 56
      * @protected
57 57
      */
58 58
     _renderOverlayContent() {
59
-        const { t } = this.props;
59
+        const { browser, t } = this.props;
60 60
 
61 61
         return (
62 62
             <div>
@@ -64,12 +64,18 @@ class UserMediaPermissionsOverlay extends AbstractOverlay {
64 64
                     <span className = 'inlay__icon icon-microphone' />
65 65
                     <span className = 'inlay__icon icon-camera' />
66 66
                     <h3 className = 'inlay__title'>
67
-                        { t('startupoverlay.title',
68
-                            { postProcess: 'resolveAppName' }) }
67
+                        {
68
+                            t(
69
+                                'startupoverlay.title',
70
+                                { postProcess: 'resolveAppName' })
71
+                        }
69 72
                     </h3>
70 73
                     <span className = 'inlay__text'>
71
-                        { translateToHTML(t,
72
-                            `userMedia.${this.props.browser}GrantPermissions`)}
74
+                        {
75
+                            translateToHTML(
76
+                                t,
77
+                                `userMedia.${browser}GrantPermissions`)
78
+                        }
73 79
                     </span>
74 80
                 </div>
75 81
                 <div className = 'policy overlay__policy'>

+ 9
- 2
react/features/room-lock/components/RoomLockPrompt.native.js Parādīt failu

@@ -2,9 +2,9 @@ import React, { Component } from 'react';
2 2
 import Prompt from 'react-native-prompt';
3 3
 import { connect } from 'react-redux';
4 4
 
5
-import { endRoomLockRequest } from '../actions';
5
+import { translate } from '../../base/i18n';
6 6
 
7
-import { translate } from '../../base/translation';
7
+import { endRoomLockRequest } from '../actions';
8 8
 
9 9
 /**
10 10
  * Implements a React Component which prompts the user for a password to lock  a
@@ -24,6 +24,13 @@ class RoomLockPrompt extends Component {
24 24
          */
25 25
         conference: React.PropTypes.object,
26 26
         dispatch: React.PropTypes.func,
27
+
28
+        /**
29
+         * The function to translate human-readable text.
30
+         *
31
+         * @public
32
+         * @type {Function}
33
+         */
27 34
         t: React.PropTypes.func
28 35
     }
29 36
 

+ 15
- 9
react/features/unsupported-browser/components/UnsupportedDesktopBrowser.js Parādīt failu

@@ -2,19 +2,19 @@
2 2
 
3 3
 import React, { Component } from 'react';
4 4
 
5
+import { translate } from '../../base/i18n';
5 6
 import { Platform } from '../../base/react';
6
-import { translate } from '../../base/translation';
7 7
 
8 8
 import { CHROME, FIREFOX, IE, SAFARI } from './browserLinks';
9 9
 import HideNotificationBarStyle from './HideNotificationBarStyle';
10 10
 
11 11
 /**
12
- * The CSS style namespace of UnsupportedDesktopBrowser.
12
+ * The namespace of the CSS styles of UnsupportedDesktopBrowser.
13 13
  *
14 14
  * @private
15 15
  * @type {string}
16 16
  */
17
-const _NS = 'unsupported-desktop-browser';
17
+const _SNS = 'unsupported-desktop-browser';
18 18
 
19 19
 /**
20 20
  * React component representing unsupported browser page.
@@ -28,6 +28,12 @@ class UnsupportedDesktopBrowser extends Component {
28 28
      * @static
29 29
      */
30 30
     static propTypes = {
31
+        /**
32
+         * The function to translate human-readable text.
33
+         *
34
+         * @public
35
+         * @type {Function}
36
+         */
31 37
         t: React.PropTypes.func
32 38
     }
33 39
 
@@ -38,17 +44,17 @@ class UnsupportedDesktopBrowser extends Component {
38 44
      */
39 45
     render() {
40 46
         return (
41
-            <div className = { _NS }>
42
-                <h2 className = { `${_NS}__title` }>
47
+            <div className = { _SNS }>
48
+                <h2 className = { `${_SNS}__title` }>
43 49
                     It looks like you're using a browser we don't support.
44 50
                 </h2>
45
-                <p className = { `${_NS}__description` }>
51
+                <p className = { `${_SNS}__description` }>
46 52
                     Please try again with the latest version of&nbsp;
47 53
                     <a
48
-                        className = { `${_NS}__link` }
54
+                        className = { `${_SNS}__link` }
49 55
                         href = { CHROME } >Chrome</a>,&nbsp;
50 56
                     <a
51
-                        className = { `${_NS}__link` }
57
+                        className = { `${_SNS}__link` }
52 58
                         href = { FIREFOX }>Firefox</a> or&nbsp;
53 59
                     {
54 60
                         this._renderOSSpecificBrowserDownloadLink()
@@ -84,7 +90,7 @@ class UnsupportedDesktopBrowser extends Component {
84 90
         if (typeof link !== 'undefined') {
85 91
             return (
86 92
                 <a
87
-                    className = { `${_NS}__link` }
93
+                    className = { `${_SNS}__link` }
88 94
                     href = { link }>
89 95
                     {
90 96
                         text

+ 44
- 17
react/features/unsupported-browser/components/UnsupportedMobileBrowser.js Parādīt failu

@@ -3,16 +3,33 @@
3 3
 import React, { Component } from 'react';
4 4
 import { connect } from 'react-redux';
5 5
 
6
+import { translate, translateToHTML } from '../../base/i18n';
6 7
 import { Platform } from '../../base/react';
7
-import { translate, translateToHTML } from '../../base/translation';
8 8
 
9 9
 import HideNotificationBarStyle from './HideNotificationBarStyle';
10 10
 
11
+/**
12
+ * The namespace of the CSS styles of UnsupportedMobileBrowser.
13
+ *
14
+ * @private
15
+ * @type {string}
16
+ */
17
+const _SNS = 'unsupported-mobile-browser';
18
+
19
+/**
20
+ * The namespace of the i18n/translation keys of UnsupportedMobileBrowser.
21
+ *
22
+ * @private
23
+ * @type {string}
24
+ */
25
+const _TNS = 'unsupportedBrowser';
26
+
11 27
 /**
12 28
  * The map of platforms to URLs at which the mobile app for the associated
13 29
  * platform is available for download.
14 30
  *
15 31
  * @private
32
+ * @type {Array<string>}
16 33
  */
17 34
 const _URLS = {
18 35
     android: 'https://play.google.com/store/apps/details?id=org.jitsi.meet',
@@ -41,6 +58,13 @@ class UnsupportedMobileBrowser extends Component {
41 58
          * @type {string}
42 59
          */
43 60
         _room: React.PropTypes.string,
61
+
62
+        /**
63
+         * The function to translate human-readable text.
64
+         *
65
+         * @public
66
+         * @type {Function}
67
+         */
44 68
         t: React.PropTypes.func
45 69
     }
46 70
 
@@ -52,8 +76,7 @@ class UnsupportedMobileBrowser extends Component {
52 76
      */
53 77
     componentWillMount() {
54 78
         const joinText
55
-            = this.props._room ? 'unsupportedPage.joinConversation'
56
-                : 'unsupportedPage.startConference';
79
+            = this.props._room ? 'joinConversation' : 'startConference';
57 80
 
58 81
         // If the user installed the app while this Component was displayed
59 82
         // (e.g. the user clicked the Download the App button), then we would
@@ -75,32 +98,36 @@ class UnsupportedMobileBrowser extends Component {
75 98
      * @returns {ReactElement}
76 99
      */
77 100
     render() {
78
-        const ns = 'unsupported-mobile-browser';
79
-        const downloadButtonClassName = `${ns}__button ${ns}__button_primary`;
80 101
         const { t } = this.props;
81 102
 
103
+        const downloadButtonClassName
104
+            = `${_SNS}__button ${_SNS}__button_primary`;
105
+
82 106
         return (
83
-            <div className = { ns }>
84
-                <div className = { `${ns}__body` }>
107
+            <div className = { _SNS }>
108
+                <div className = { `${_SNS}__body` }>
85 109
                     <img
86
-                        className = { `${ns}__logo` }
110
+                        className = { `${_SNS}__logo` }
87 111
                         src = 'images/logo-blue.svg' />
88
-                    <p className = { `${ns}__text` }>
89
-                        { translateToHTML(t,
90
-                            'unsupportedPage.joinConversationMobile',
91
-                            { postProcess: 'resolveAppName' }) }
112
+                    <p className = { `${_SNS}__text` }>
113
+                        {
114
+                            translateToHTML(
115
+                                t,
116
+                                `${_TNS}.appNotInstalled`,
117
+                                { postProcess: 'resolveAppName' })
118
+                        }
92 119
                     </p>
93 120
                     <a href = { _URLS[Platform.OS] }>
94 121
                         <button className = { downloadButtonClassName }>
95
-                            { t('unsupportedPage.downloadApp') }
122
+                            { t(`${_TNS}.downloadApp`) }
96 123
                         </button>
97 124
                     </a>
98
-                    <p className = { `${ns}__text ${ns}__text_small` }>
99
-                        { translateToHTML(t, 'unsupportedPage.availableApp') }
125
+                    <p className = { `${_SNS}__text ${_SNS}__text_small` }>
126
+                        { translateToHTML(t, `${_TNS}.appInstalled`) }
100 127
                     </p>
101 128
                     <a href = { this.state.joinURL }>
102
-                        <button className = { `${ns}__button` }>
103
-                            { t(this.state.joinText) }
129
+                        <button className = { `${_SNS}__button` }>
130
+                            { t(`${_TNS}.${this.state.joinText}`) }
104 131
                         </button>
105 132
                     </a>
106 133
                 </div>

+ 1
- 2
react/features/welcome/components/WelcomePage.native.js Parādīt failu

@@ -2,14 +2,13 @@ import React from 'react';
2 2
 import { Text, TextInput, TouchableHighlight, View } from 'react-native';
3 3
 import { connect } from 'react-redux';
4 4
 
5
+import { translate } from '../../base/i18n';
5 6
 import { Link } from '../../base/react';
6 7
 import { ColorPalette } from '../../base/styles';
7 8
 
8 9
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
9 10
 import { styles } from './styles';
10 11
 
11
-import { translate } from '../../base/translation';
12
-
13 12
 /**
14 13
  * The URL at which the privacy policy is available to the user.
15 14
  */

+ 6
- 9
react/features/welcome/components/WelcomePage.web.js Parādīt failu

@@ -3,12 +3,11 @@
3 3
 import React from 'react';
4 4
 import { connect } from 'react-redux';
5 5
 
6
+import { translate } from '../../base/i18n';
6 7
 import { Watermarks } from '../../base/react';
7 8
 
8 9
 import { AbstractWelcomePage, _mapStateToProps } from './AbstractWelcomePage';
9 10
 
10
-import { translate } from '../../base/translation';
11
-
12 11
 /* eslint-disable require-jsdoc */
13 12
 
14 13
 /**
@@ -142,19 +141,17 @@ class WelcomePage extends AbstractWelcomePage {
142 141
      */
143 142
     _renderFeature(index) {
144 143
         const { t } = this.props;
144
+        const tns = `welcomepage.feature${index}`;
145 145
 
146 146
         return (
147 147
             <div
148 148
                 className = 'feature_holder'
149 149
                 key = { index } >
150
-                <div
151
-                    className = 'feature_icon'>
152
-                    { t(`welcomepage.feature${index}.title`) }
150
+                <div className = 'feature_icon'>
151
+                    { t(`${tns}.title`) }
153 152
                 </div>
154
-                <div
155
-                    className = 'feature_description'>
156
-                    { t(`welcomepage.feature${index}.content`,
157
-                        { postProcess: 'resolveAppName' }) }
153
+                <div className = 'feature_description'>
154
+                    { t(`${tns}.content`, { postProcess: 'resolveAppName' }) }
158 155
                 </div>
159 156
             </div>
160 157
         );

+ 0
- 27
service/translation/languages.js Parādīt failu

@@ -1,27 +0,0 @@
1
-export default {
2
-    getLanguages : function () {
3
-        var languages = [];
4
-        for (var lang in this)
5
-        {
6
-            if (typeof this[lang] === "string")
7
-                languages.push(this[lang]);
8
-        }
9
-        return languages;
10
-    },
11
-    EN: "en",
12
-
13
-    BG: "bg",
14
-    DE: "de",
15
-    ES: "es",
16
-    FR: "fr",
17
-    HY: "hy",
18
-    IT: "it",
19
-    OC: "oc",
20
-    PL: "pl",
21
-    PTBR: "ptBR",
22
-    RU: "ru",
23
-    SK: "sk",
24
-    SL: "sl",
25
-    SV: "sv",
26
-    TR: "tr"
27
-};

Notiek ielāde…
Atcelt
Saglabāt