diff --git a/app/i18n/index.js b/app/i18n/index.js index 578c0bc45d..ff37535142 100644 --- a/app/i18n/index.js +++ b/app/i18n/index.js @@ -9,11 +9,11 @@ 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', @@ -21,7 +21,7 @@ export const LANGUAGES = [ file: require('./locales/de').default }, { label: 'Español (ES)', - value: 'es', + value: 'es-ES', file: require('./locales/es-ES').default }, { label: 'Français', @@ -29,11 +29,11 @@ export const LANGUAGES = [ 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', diff --git a/app/sagas/login.js b/app/sagas/login.js index 7b64de0bc8..bd561cf6f3 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -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'; @@ -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) {