Moved getCurrentUserLocale to mattermost-redux (#1652)
This commit is contained in:
parent
4517fcaa8c
commit
4d506b6e4d
4 changed files with 8 additions and 24 deletions
|
|
@ -17,6 +17,8 @@ import trLocaleData from 'react-intl/locale-data/tr';
|
|||
import ruLocaleData from 'react-intl/locale-data/ru';
|
||||
import zhLocaleData from 'react-intl/locale-data/zh';
|
||||
|
||||
import {DEFAULT_LOCALE} from 'mattermost-redux/constants/general';
|
||||
|
||||
import de from 'assets/i18n/de.json';
|
||||
import en from 'assets/i18n/en.json';
|
||||
import es from 'assets/i18n/es.json';
|
||||
|
|
@ -32,8 +34,6 @@ import ru from 'assets/i18n/ru.json';
|
|||
import zhCN from 'assets/i18n/zh-CN.json';
|
||||
import zhTW from 'assets/i18n/zh-TW.json';
|
||||
|
||||
export const DEFAULT_LOCALE = 'en';
|
||||
|
||||
const TRANSLATIONS = {
|
||||
de,
|
||||
en,
|
||||
|
|
|
|||
|
|
@ -2,30 +2,14 @@
|
|||
// See License.txt for license information.
|
||||
|
||||
import DeviceInfo from 'react-native-device-info';
|
||||
import {createSelector} from 'reselect';
|
||||
|
||||
import DEFAULT_LOCALE from 'app/i18n';
|
||||
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
|
||||
export const getCurrentUserLocale = createSelector(
|
||||
getCurrentUser,
|
||||
(currentUser) => {
|
||||
return currentUser ? currentUser.locale : '';
|
||||
}
|
||||
);
|
||||
import {DEFAULT_LOCALE} from 'mattermost-redux/constants/general';
|
||||
import {getCurrentUserLocale} from 'mattermost-redux/selectors/entities/i18n';
|
||||
|
||||
// Not a proper selector since the device locale isn't in the redux store
|
||||
export function getCurrentLocale(state) {
|
||||
const userLocale = getCurrentUserLocale(state);
|
||||
if (userLocale) {
|
||||
return userLocale;
|
||||
}
|
||||
|
||||
const deviceLocale = DeviceInfo.getDeviceLocale().split('-')[0];
|
||||
if (deviceLocale) {
|
||||
return deviceLocale;
|
||||
}
|
||||
const defaultLocale = deviceLocale || DEFAULT_LOCALE;
|
||||
|
||||
return DEFAULT_LOCALE;
|
||||
return getCurrentUserLocale(state, defaultLocale);
|
||||
}
|
||||
|
|
|
|||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -9864,7 +9864,7 @@
|
|||
}
|
||||
},
|
||||
"mattermost-redux": {
|
||||
"version": "github:mattermost/mattermost-redux#6e347814cfefdd8ef3292fef2576ff8a0f082b58",
|
||||
"version": "github:mattermost/mattermost-redux#e20f8881e6d1a8eaff76bb5ac98a2f3d884804d1",
|
||||
"requires": {
|
||||
"deep-equal": "1.0.1",
|
||||
"form-data": "2.3.1",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"fuse.js": "^3.2.0",
|
||||
"intl": "1.2.5",
|
||||
"jail-monkey": "1.0.0",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#6e347814cfefdd8ef3292fef2576ff8a0f082b58",
|
||||
"mattermost-redux": "github:mattermost/mattermost-redux#e20f8881e6d1a8eaff76bb5ac98a2f3d884804d1",
|
||||
"prop-types": "15.6.1",
|
||||
"react": "16.3.2",
|
||||
"react-intl": "2.4.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue