Skip to content

Commit

Permalink
[FIX] Language set by web client (#2488)
Browse files Browse the repository at this point in the history
Co-authored-by: Diego Mello <[email protected]>
  • Loading branch information
djorkaeffalexandre and diegolmello authored Sep 24, 2020
1 parent 0195506 commit b9a79a1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions app/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ export const LANGUAGES = [
file: require('./locales/en').default
}, {
label: '简体中文',
value: 'zh-cn',
value: 'zh-CN',
file: require('./locales/zh-CN').default
}, {
label: '繁體中文',
value: 'zh-tw',
value: 'zh-TW',
file: require('./locales/zh-TW').default
}, {
label: 'Deutsch',
value: 'de',
file: require('./locales/de').default
}, {
label: 'Español (ES)',
value: 'es',
value: 'es-ES',
file: require('./locales/es-ES').default
}, {
label: 'Français',
value: 'fr',
file: require('./locales/fr').default
}, {
label: 'Português (BR)',
value: 'pt-br',
value: 'pt-BR',
file: require('./locales/pt-BR').default
}, {
label: 'Português (PT)',
value: 'pt',
value: 'pt-PT',
file: require('./locales/pt-PT').default
}, {
label: 'Russian',
Expand Down
7 changes: 4 additions & 3 deletions app/sagas/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { roomsRequest } from '../actions/rooms';
import { toMomentLocale } from '../utils/moment';
import RocketChat from '../lib/rocketchat';
import log, { logEvent, events } from '../utils/log';
import I18n from '../i18n';
import I18n, { LANGUAGES } from '../i18n';
import database from '../lib/database';
import EventEmitter from '../utils/events';
import { inviteLinksRequest } from '../actions/inviteLinks';
Expand Down Expand Up @@ -267,8 +267,9 @@ const handleLogout = function* handleLogout({ forcedByServer }) {

const handleSetUser = function* handleSetUser({ user }) {
if (user && user.language) {
I18n.locale = user.language;
moment.locale(toMomentLocale(user.language));
const locale = LANGUAGES.find(l => l.value.toLowerCase() === user.language)?.value || user.language;
I18n.locale = locale;
moment.locale(toMomentLocale(locale));
}

if (user && user.status) {
Expand Down

0 comments on commit b9a79a1

Please sign in to comment.