mirror of https://github.com/jitsi/jitsi-meet
parent
df3545d287
commit
f20a50d8a6
@ -0,0 +1,11 @@ |
||||
// @flow
|
||||
|
||||
/** |
||||
* The type of (redux) action which signals that i18next has been initialized. |
||||
*/ |
||||
export const I18NEXT_INITIALIZED = 'I18NEXT_INITIALIZED'; |
||||
|
||||
/** |
||||
* The type of (redux) action which signals that language has been changed. |
||||
*/ |
||||
export const LANGUAGE_CHANGED = 'LANGUAGE_CHANGED'; |
@ -0,0 +1,5 @@ |
||||
// @flow
|
||||
|
||||
import { getLogger } from '../logging/functions'; |
||||
|
||||
export default getLogger('features/base/i18n'); |
@ -0,0 +1,39 @@ |
||||
// @flow
|
||||
|
||||
import { SET_DYNAMIC_BRANDING_DATA } from '../../dynamic-branding/actionTypes'; |
||||
import { MiddlewareRegistry } from '../redux'; |
||||
|
||||
import { I18NEXT_INITIALIZED, LANGUAGE_CHANGED } from './actionTypes'; |
||||
import { changeLanguageBundle } from './functions'; |
||||
import i18next from './i18next'; |
||||
import logger from './logger'; |
||||
|
||||
/** |
||||
* Implements the entry point of the middleware of the feature base/i18n. |
||||
* |
||||
* @param {Store} store - The redux store. |
||||
* @returns {Function} |
||||
*/ |
||||
MiddlewareRegistry.register(store => next => async action => { |
||||
switch (action.type) { |
||||
case I18NEXT_INITIALIZED: |
||||
case LANGUAGE_CHANGED: |
||||
case SET_DYNAMIC_BRANDING_DATA: { |
||||
const { language } = i18next; |
||||
const { labels } = action.type === SET_DYNAMIC_BRANDING_DATA |
||||
? action.value |
||||
: store.getState()['features/dynamic-branding']; |
||||
|
||||
if (language && labels && labels[language]) { |
||||
try { |
||||
await changeLanguageBundle(language, labels[language]); |
||||
} catch (err) { |
||||
logger.log('Error setting dynamic language bundle', err); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return next(action); |
||||
}); |
Loading…
Reference in new issue