From 3f378b7aaee16c06ea8dffb7c902b6330bec18cb Mon Sep 17 00:00:00 2001 From: Roman Drozd Date: Wed, 4 Nov 2020 01:16:02 +0100 Subject: [PATCH] Fix notifications (they were displayed always in English) --- app/src/RoomClient.js | 17 +++++++++++------ app/src/index.js | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/RoomClient.js b/app/src/RoomClient.js index 2d95c09a..2683985e 100644 --- a/app/src/RoomClient.js +++ b/app/src/RoomClient.js @@ -18,8 +18,8 @@ import * as notificationActions from './actions/notificationActions'; import * as transportActions from './actions/transportActions'; import Spotlights from './Spotlights'; import { permissions } from './permissions'; -// import { updateIntl } from 'react-intl-redux'; import * as locales from './translations/locales'; +import { createIntl } from 'react-intl'; let createTorrent; @@ -116,8 +116,6 @@ export default class RoomClient static init(data) { store = data.store; - intl = data.intl; - } constructor( @@ -259,7 +257,7 @@ export default class RoomClient this._startDevicesListener(); - this.setLocale(store.getState().intl.locale); + this.setLocale(); } @@ -502,10 +500,11 @@ export default class RoomClient }); } - setLocale(locale) + setLocale(locale = null) { if (locale === null) locale = locales.detect(); + const one = locales.loadOne(locale); store.dispatch(intlActions.updateIntl({ @@ -514,7 +513,13 @@ export default class RoomClient list : locales.getList() })); - document.documentElement.lang = one.locale[0].toUpperCase(); + intl = createIntl({ + locale : store.getState().intl.locale, + messages : store.getState().intl.messages + }); + + document.documentElement.lang = store.getState().intl.locale.toUpperCase(); + } login(roomId = this._roomId) diff --git a/app/src/index.js b/app/src/index.js index 4dd00f70..08a82956 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -57,7 +57,7 @@ const logger = new Logger(); let roomClient; -RoomClient.init({ store, intl }); +RoomClient.init({ store }); const theme = createMuiTheme(window.config.theme);