[FIX] Language set by web client (#2488)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
0195506549
commit
b9a79a1724
|
@ -9,11 +9,11 @@ export const LANGUAGES = [
|
||||||
file: require('./locales/en').default
|
file: require('./locales/en').default
|
||||||
}, {
|
}, {
|
||||||
label: '简体中文',
|
label: '简体中文',
|
||||||
value: 'zh-cn',
|
value: 'zh-CN',
|
||||||
file: require('./locales/zh-CN').default
|
file: require('./locales/zh-CN').default
|
||||||
}, {
|
}, {
|
||||||
label: '繁體中文',
|
label: '繁體中文',
|
||||||
value: 'zh-tw',
|
value: 'zh-TW',
|
||||||
file: require('./locales/zh-TW').default
|
file: require('./locales/zh-TW').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Deutsch',
|
label: 'Deutsch',
|
||||||
|
@ -21,7 +21,7 @@ export const LANGUAGES = [
|
||||||
file: require('./locales/de').default
|
file: require('./locales/de').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Español (ES)',
|
label: 'Español (ES)',
|
||||||
value: 'es',
|
value: 'es-ES',
|
||||||
file: require('./locales/es-ES').default
|
file: require('./locales/es-ES').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Français',
|
label: 'Français',
|
||||||
|
@ -29,11 +29,11 @@ export const LANGUAGES = [
|
||||||
file: require('./locales/fr').default
|
file: require('./locales/fr').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Português (BR)',
|
label: 'Português (BR)',
|
||||||
value: 'pt-br',
|
value: 'pt-BR',
|
||||||
file: require('./locales/pt-BR').default
|
file: require('./locales/pt-BR').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Português (PT)',
|
label: 'Português (PT)',
|
||||||
value: 'pt',
|
value: 'pt-PT',
|
||||||
file: require('./locales/pt-PT').default
|
file: require('./locales/pt-PT').default
|
||||||
}, {
|
}, {
|
||||||
label: 'Russian',
|
label: 'Russian',
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { roomsRequest } from '../actions/rooms';
|
||||||
import { toMomentLocale } from '../utils/moment';
|
import { toMomentLocale } from '../utils/moment';
|
||||||
import RocketChat from '../lib/rocketchat';
|
import RocketChat from '../lib/rocketchat';
|
||||||
import log, { logEvent, events } from '../utils/log';
|
import log, { logEvent, events } from '../utils/log';
|
||||||
import I18n from '../i18n';
|
import I18n, { LANGUAGES } from '../i18n';
|
||||||
import database from '../lib/database';
|
import database from '../lib/database';
|
||||||
import EventEmitter from '../utils/events';
|
import EventEmitter from '../utils/events';
|
||||||
import { inviteLinksRequest } from '../actions/inviteLinks';
|
import { inviteLinksRequest } from '../actions/inviteLinks';
|
||||||
|
@ -267,8 +267,9 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
|
||||||
|
|
||||||
const handleSetUser = function* handleSetUser({ user }) {
|
const handleSetUser = function* handleSetUser({ user }) {
|
||||||
if (user && user.language) {
|
if (user && user.language) {
|
||||||
I18n.locale = user.language;
|
const locale = LANGUAGES.find(l => l.value.toLowerCase() === user.language)?.value || user.language;
|
||||||
moment.locale(toMomentLocale(user.language));
|
I18n.locale = locale;
|
||||||
|
moment.locale(toMomentLocale(locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user && user.status) {
|
if (user && user.status) {
|
||||||
|
|
Loading…
Reference in New Issue