mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-18 19:01:38 +03:00
Moved application conteiner alert messages to language file
This commit is contained in:
parent
64447893d4
commit
d60d2ea11b
@ -206,7 +206,8 @@
|
||||
"removed": "Removed",
|
||||
"same_user": "This user already added to list",
|
||||
"unknow_error": "An error occurred",
|
||||
"error": "Error"
|
||||
"error": "Error",
|
||||
"fetch_error": "Fetching data from server failed, please try again or notify us at info@esteem.app"
|
||||
},
|
||||
"post": {
|
||||
"reblog_alert": "Are you sure you want to reblog?",
|
||||
|
16
src/index.js
16
src/index.js
@ -1,7 +1,19 @@
|
||||
import React from 'react';
|
||||
import { Provider, connect } from 'react-redux';
|
||||
import { PersistGate } from 'redux-persist/integration/react';
|
||||
import { IntlProvider } from 'react-intl';
|
||||
import { IntlProvider, addLocaleData } from 'react-intl';
|
||||
|
||||
import en from 'react-intl/locale-data/en';
|
||||
import id from 'react-intl/locale-data/id';
|
||||
import ru from 'react-intl/locale-data/ru';
|
||||
import de from 'react-intl/locale-data/de';
|
||||
import it from 'react-intl/locale-data/it';
|
||||
import hu from 'react-intl/locale-data/hu';
|
||||
import tr from 'react-intl/locale-data/tr';
|
||||
import ko from 'react-intl/locale-data/ko';
|
||||
import lt from 'react-intl/locale-data/lt';
|
||||
import pt from 'react-intl/locale-data/pt';
|
||||
import fa from 'react-intl/locale-data/fa';
|
||||
|
||||
import { flattenMessages } from './utils/flattenMessages';
|
||||
import messages from './config/locales';
|
||||
@ -9,6 +21,8 @@ import messages from './config/locales';
|
||||
import Application from './screens/application';
|
||||
import { store, persistor } from './redux/store/store';
|
||||
|
||||
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
|
||||
|
||||
const _renderApp = ({ locale }) => (
|
||||
<PersistGate loading={null} persistor={persistor}>
|
||||
<IntlProvider locale={locale} messages={flattenMessages(messages[locale])}>
|
||||
|
@ -7,24 +7,11 @@ import get from 'lodash/get';
|
||||
import AppCenter from 'appcenter';
|
||||
import changeNavigationBarColor from 'react-native-navigation-bar-color';
|
||||
import { connect } from 'react-redux';
|
||||
import { addLocaleData } from 'react-intl';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { NavigationActions } from 'react-navigation';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import EStyleSheet from 'react-native-extended-stylesheet';
|
||||
|
||||
// Languages
|
||||
import en from 'react-intl/locale-data/en';
|
||||
import id from 'react-intl/locale-data/id';
|
||||
import ru from 'react-intl/locale-data/ru';
|
||||
import de from 'react-intl/locale-data/de';
|
||||
import it from 'react-intl/locale-data/it';
|
||||
import hu from 'react-intl/locale-data/hu';
|
||||
import tr from 'react-intl/locale-data/tr';
|
||||
import ko from 'react-intl/locale-data/ko';
|
||||
import lt from 'react-intl/locale-data/lt';
|
||||
import pt from 'react-intl/locale-data/pt';
|
||||
import fa from 'react-intl/locale-data/fa';
|
||||
|
||||
// Constants
|
||||
import AUTH_TYPE from '../../../constants/authType';
|
||||
import ROUTES from '../../../constants/routeNames';
|
||||
@ -79,8 +66,6 @@ import { encryptKey } from '../../../utils/crypto';
|
||||
import darkTheme from '../../../themes/darkTheme';
|
||||
import lightTheme from '../../../themes/lightTheme';
|
||||
|
||||
addLocaleData([...en, ...ru, ...de, ...id, ...it, ...hu, ...tr, ...ko, ...pt, ...lt, ...fa]);
|
||||
|
||||
class ApplicationContainer extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@ -203,11 +188,11 @@ class ApplicationContainer extends Component {
|
||||
if (get(result, 'title')) {
|
||||
content = result;
|
||||
} else {
|
||||
this._handleAlert('No existing post');
|
||||
this._handleAlert('deep_link.no_existing_post');
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this._handleAlert('No existing post');
|
||||
this._handleAlert('deep_link.no_existing_post');
|
||||
});
|
||||
|
||||
routeName = ROUTES.SCREENS.POST;
|
||||
@ -216,7 +201,7 @@ class ApplicationContainer extends Component {
|
||||
profile = await getUser(author);
|
||||
|
||||
if (!profile) {
|
||||
this._handleAlert('No existing user');
|
||||
this._handleAlert('deep_link.no_existing_user');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -238,8 +223,13 @@ class ApplicationContainer extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleAlert = (title = null, text = null) => {
|
||||
Alert.alert(title, text);
|
||||
_handleAlert = (text = null, title = null) => {
|
||||
const { intl } = this.props;
|
||||
|
||||
Alert.alert(
|
||||
intl.formatMessage({ id: title || 'alert.warning' }),
|
||||
intl.formatMessage({ id: text || 'alert.unknow_error' }),
|
||||
);
|
||||
};
|
||||
|
||||
_handleAppStateChange = nextAppState => {
|
||||
@ -337,10 +327,6 @@ class ApplicationContainer extends Component {
|
||||
if (isConnected !== status) {
|
||||
dispatch(setConnectivityStatus(status));
|
||||
}
|
||||
|
||||
// TODO: solve this work arround
|
||||
// NetInfo.isConnected.removeEventListener('connectionChange', this._handleConntectionChange);
|
||||
// NetInfo.isConnected.addEventListener('connectionChange', this._handleConntectionChange);
|
||||
};
|
||||
|
||||
_onBackPress = () => {
|
||||
@ -442,7 +428,7 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
|
||||
_fetchUserDataFromDsteem = async realmObject => {
|
||||
const { dispatch } = this.props;
|
||||
const { dispatch, intl } = this.props;
|
||||
|
||||
await getUser(realmObject.username)
|
||||
.then(accountData => {
|
||||
@ -453,9 +439,9 @@ class ApplicationContainer extends Component {
|
||||
this._connectNotificationServer(accountData.name);
|
||||
})
|
||||
.catch(err => {
|
||||
this._handleAlert();
|
||||
Alert.alert(
|
||||
`Fetching data from server failed, please try again or notify us at info@esteem.app
|
||||
\n${err.message.substr(0, 20)}`,
|
||||
`${intl.formatMessage({ id: 'alert.fetch_error' })} \n${err.message.substr(0, 20)}`,
|
||||
);
|
||||
});
|
||||
};
|
||||
@ -507,6 +493,7 @@ class ApplicationContainer extends Component {
|
||||
otherAccounts,
|
||||
currentAccount: { name, local },
|
||||
dispatch,
|
||||
intl,
|
||||
} = this.props;
|
||||
|
||||
removeUserData(name)
|
||||
@ -535,8 +522,7 @@ class ApplicationContainer extends Component {
|
||||
})
|
||||
.catch(err => {
|
||||
Alert.alert(
|
||||
`Fetching data from server failed, please try again or notify us at info@esteem.app
|
||||
\n${err.substr(0, 20)}`,
|
||||
`${intl.formatMessage({ id: 'alert.fetch_error' })} \n${err.message.substr(0, 20)}`,
|
||||
);
|
||||
});
|
||||
};
|
||||
@ -622,4 +608,4 @@ export default connect(
|
||||
...bindActionCreators({ fetchGlobalProperties }, dispatch),
|
||||
},
|
||||
}),
|
||||
)(ApplicationContainer);
|
||||
)(injectIntl(ApplicationContainer));
|
||||
|
Loading…
Reference in New Issue
Block a user