diff --git a/modules/translation/translation.js b/modules/translation/translation.js index 64510f44d..1ad2a3e6c 100644 --- a/modules/translation/translation.js +++ b/modules/translation/translation.js @@ -23,20 +23,7 @@ class Translation { /** * */ - generateTranslationHTML(key: string, options: Object) { - const optAttr - = options ? ` data-i18n-options='${JSON.stringify(options)}'` : ''; - - // XXX i18next expects undefined if options are missing. - const text = i18next.t(key, options ? options : undefined); - - return `${text}`; - } - - /** - * - */ - init() { + constructor() { jqueryI18next.init(i18next, $, { useOptionsAttr: true }); if (i18next.isInitialized) { @@ -48,6 +35,19 @@ class Translation { i18next.on('languageChanged', _onI18nInitialized); } + /** + * + */ + generateTranslationHTML(key: string, options: Object) { + const optAttr + = options ? ` data-i18n-options='${JSON.stringify(options)}'` : ''; + + // XXX i18next expects undefined if options are missing. + const text = i18next.t(key, options ? options : undefined); + + return `${text}`; + } + /** * */ diff --git a/react/features/base/i18n/index.js b/react/features/base/i18n/index.js index 59657a34e..41ecb0cd8 100644 --- a/react/features/base/i18n/index.js +++ b/react/features/base/i18n/index.js @@ -4,5 +4,3 @@ export * from './functions'; // TODO Eventually (e.g. when the non-React Web app is rewritten into React), it // should not be necessary to export i18next. export { default as i18next, DEFAULT_LANGUAGE, LANGUAGES } from './i18next'; - -import './middleware'; diff --git a/react/features/base/i18n/middleware.js b/react/features/base/i18n/middleware.js deleted file mode 100644 index f498c0f3f..000000000 --- a/react/features/base/i18n/middleware.js +++ /dev/null @@ -1,50 +0,0 @@ -/* @flow */ -// FIXME: Using '../config/actionTypes' instead of '../config' is a quick fix -// for the dial-in info page. Importing '../config' results in JitsiMeetJS -// undefined error (/base/config imports /app which import /lib-jitsi-meet/). -import { SET_CONFIG } from '../config/actionTypes'; -import { MiddlewareRegistry } from '../redux'; - -declare var APP: Object; - -/** - * The redux middleware of the feature base/i18n. - * - * @param {Store} store - The redux store. - * @returns {Function} - * @private - */ -MiddlewareRegistry.register(store => next => action => { - switch (action.type) { - case SET_CONFIG: - return _setConfig(store, next, action); - } - - return next(action); -}); - -/** - * Notifies the feature base/i18n that the action SET_CONFIG is being dispatched - * within a specific redux store. - * - * @param {Store} store - The redux store in which the specified action is being - * dispatched. - * @param {Dispatch} next - The redux dispatch function to dispatch the - * specified action to the specified store. - * @param {Action} action - The redux action SET_CONFIG which is being - * dispatched in the specified store. - * @private - * @returns {Object} The new state that is the result of the reduction of the - * specified action. - */ -function _setConfig({ getState }, next, action) { - const oldValue = getState()['features/base/config']; - const result = next(action); - const newValue = getState()['features/base/config']; - - if (oldValue !== newValue && typeof APP === 'object') { - APP.translation.init(); - } - - return result; -}