diff --git a/app/soapbox/actions/auth.js b/app/soapbox/actions/auth.js
index ff4e1390a..e8463a833 100644
--- a/app/soapbox/actions/auth.js
+++ b/app/soapbox/actions/auth.js
@@ -1,3 +1,4 @@
+import { defineMessages } from 'react-intl';
import api, { baseClient } from '../api';
import { importFetchedAccount } from './importer';
import snackbar from 'soapbox/actions/snackbar';
@@ -39,6 +40,11 @@ export const REVOKE_TOKEN_REQUEST = 'REVOKE_TOKEN_REQUEST';
export const REVOKE_TOKEN_SUCCESS = 'REVOKE_TOKEN_SUCCESS';
export const REVOKE_TOKEN_FAIL = 'REVOKE_TOKEN_FAIL';
+const messages = defineMessages({
+ loggedOut: { id: 'auth.logged_out', defaultMessage: 'Logged out.' },
+ invalidCredentials: { id: 'auth.invalid_credentials', defaultMessage: 'Wrong username or password' },
+});
+
const noOp = () => () => new Promise(f => f());
function createAppAndToken() {
@@ -150,7 +156,7 @@ export function verifyCredentials(token) {
};
}
-export function logIn(username, password) {
+export function logIn(intl, username, password) {
return (dispatch, getState) => {
return dispatch(createAppAndToken()).then(() => {
return dispatch(createUserToken(username, password));
@@ -160,14 +166,14 @@ export function logIn(username, password) {
} else if(error.response.data.error) {
dispatch(snackbar.error(error.response.data.error));
} else {
- dispatch(snackbar.error('Wrong username or password'));
+ dispatch(snackbar.error(intl.formatMessage(messages.invalidCredentials)));
}
throw error;
});
};
}
-export function logOut() {
+export function logOut(intl) {
return (dispatch, getState) => {
const state = getState();
const me = state.get('me');
@@ -178,7 +184,7 @@ export function logOut() {
token: state.getIn(['auth', 'users', me, 'access_token']),
}).finally(() => {
dispatch({ type: AUTH_LOGGED_OUT, accountId: me });
- dispatch(snackbar.success('Logged out.'));
+ dispatch(snackbar.success(intl.formatMessage(messages.loggedOut)));
});
};
}
@@ -250,7 +256,7 @@ export function changeEmail(email, password) {
};
}
-export function deleteAccount(password) {
+export function deleteAccount(intl, password) {
return (dispatch, getState) => {
dispatch({ type: DELETE_ACCOUNT_REQUEST });
return api(getState).post('/api/pleroma/delete_account', {
@@ -259,7 +265,7 @@ export function deleteAccount(password) {
if (response.data.error) throw response.data.error; // This endpoint returns HTTP 200 even on failure
dispatch({ type: DELETE_ACCOUNT_SUCCESS, response });
dispatch({ type: AUTH_LOGGED_OUT });
- dispatch(snackbar.success('Logged out.'));
+ dispatch(snackbar.success(intl.formatMessage(messages.loggedOut)));
}).catch(error => {
dispatch({ type: DELETE_ACCOUNT_FAIL, error, skipAlert: true });
throw error;
diff --git a/app/soapbox/actions/filters.js b/app/soapbox/actions/filters.js
index ab2767a14..b5964cd38 100644
--- a/app/soapbox/actions/filters.js
+++ b/app/soapbox/actions/filters.js
@@ -1,3 +1,4 @@
+import { defineMessages } from 'react-intl';
import api from '../api';
import snackbar from 'soapbox/actions/snackbar';
import { isLoggedIn } from 'soapbox/utils/auth';
@@ -14,6 +15,11 @@ export const FILTERS_DELETE_REQUEST = 'FILTERS_DELETE_REQUEST';
export const FILTERS_DELETE_SUCCESS = 'FILTERS_DELETE_SUCCESS';
export const FILTERS_DELETE_FAIL = 'FILTERS_DELETE_FAIL';
+const messages = defineMessages({
+ added: { id: 'filters.added', defaultMessage: 'Filter added.' },
+ removed: { id: 'filters.removed', defaultMessage: 'Filter deleted.' },
+});
+
export const fetchFilters = () => (dispatch, getState) => {
if (!isLoggedIn(getState)) return;
@@ -37,7 +43,7 @@ export const fetchFilters = () => (dispatch, getState) => {
}));
};
-export function createFilter(phrase, expires_at, context, whole_word, irreversible) {
+export function createFilter(intl, phrase, expires_at, context, whole_word, irreversible) {
return (dispatch, getState) => {
dispatch({ type: FILTERS_CREATE_REQUEST });
return api(getState).post('/api/v1/filters', {
@@ -48,7 +54,7 @@ export function createFilter(phrase, expires_at, context, whole_word, irreversib
expires_at,
}).then(response => {
dispatch({ type: FILTERS_CREATE_SUCCESS, filter: response.data });
- dispatch(snackbar.success('Filter added.'));
+ dispatch(snackbar.success(intl.formatMessage(messages.added)));
}).catch(error => {
dispatch({ type: FILTERS_CREATE_FAIL, error });
});
@@ -56,12 +62,12 @@ export function createFilter(phrase, expires_at, context, whole_word, irreversib
}
-export function deleteFilter(id) {
+export function deleteFilter(intl, id) {
return (dispatch, getState) => {
dispatch({ type: FILTERS_DELETE_REQUEST });
return api(getState).delete('/api/v1/filters/'+id).then(response => {
dispatch({ type: FILTERS_DELETE_SUCCESS, filter: response.data });
- dispatch(snackbar.success('Filter deleted.'));
+ dispatch(snackbar.success(intl.formatMessage(messages.removed)));
}).catch(error => {
dispatch({ type: FILTERS_DELETE_FAIL, error });
});
diff --git a/app/soapbox/actions/import_data.js b/app/soapbox/actions/import_data.js
index 6a0a3c254..acf205f94 100644
--- a/app/soapbox/actions/import_data.js
+++ b/app/soapbox/actions/import_data.js
@@ -1,3 +1,4 @@
+import { defineMessages } from 'react-intl';
import api from '../api';
import snackbar from 'soapbox/actions/snackbar';
@@ -13,13 +14,19 @@ export const IMPORT_MUTES_REQUEST = 'IMPORT_MUTES_REQUEST';
export const IMPORT_MUTES_SUCCESS = 'IMPORT_MUTES_SUCCESS';
export const IMPORT_MUTES_FAIL = 'IMPORT_MUTES_FAIL';
-export function importFollows(params) {
+const messages = defineMessages({
+ blocksSuccess: { id: 'import_data.success.blocks', defaultMessage: 'Blocks imported successfully' },
+ followersSuccess: { id: 'import_data.success.followers', defaultMessage: 'Followers imported successfully' },
+ mutesSuccess: { id: 'import_data.success.mutes', defaultMessage: 'Mutes imported successfully' },
+});
+
+export function importFollows(intl, params) {
return (dispatch, getState) => {
dispatch({ type: IMPORT_FOLLOWS_REQUEST });
return api(getState)
.post('/api/pleroma/follow_import', params)
.then(response => {
- dispatch(snackbar.success('Followers imported successfully'));
+ dispatch(snackbar.success(intl.formatMessage(messages.followersSuccess)));
dispatch({ type: IMPORT_FOLLOWS_SUCCESS, config: response.data });
}).catch(error => {
dispatch({ type: IMPORT_FOLLOWS_FAIL, error });
@@ -27,13 +34,13 @@ export function importFollows(params) {
};
}
-export function importBlocks(params) {
+export function importBlocks(intl, params) {
return (dispatch, getState) => {
dispatch({ type: IMPORT_BLOCKS_REQUEST });
return api(getState)
.post('/api/pleroma/blocks_import', params)
.then(response => {
- dispatch(snackbar.success('Blocks imported successfully'));
+ dispatch(snackbar.success(intl.formatMessage(messages.blocksSuccess)));
dispatch({ type: IMPORT_BLOCKS_SUCCESS, config: response.data });
}).catch(error => {
dispatch({ type: IMPORT_BLOCKS_FAIL, error });
@@ -41,13 +48,13 @@ export function importBlocks(params) {
};
}
-export function importMutes(params) {
+export function importMutes(intl, params) {
return (dispatch, getState) => {
dispatch({ type: IMPORT_MUTES_REQUEST });
return api(getState)
.post('/api/pleroma/mutes_import', params)
.then(response => {
- dispatch(snackbar.success('Mutes imported successfully'));
+ dispatch(snackbar.success(intl.formatMessage(messages.mutesSuccess)));
dispatch({ type: IMPORT_MUTES_SUCCESS, config: response.data });
}).catch(error => {
dispatch({ type: IMPORT_MUTES_FAIL, error });
diff --git a/app/soapbox/actions/interactions.js b/app/soapbox/actions/interactions.js
index 73da37c96..a6f32c607 100644
--- a/app/soapbox/actions/interactions.js
+++ b/app/soapbox/actions/interactions.js
@@ -1,3 +1,4 @@
+import { defineMessages } from 'react-intl';
import api from '../api';
import { importFetchedAccounts, importFetchedStatus } from './importer';
import snackbar from 'soapbox/actions/snackbar';
@@ -43,6 +44,11 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST';
export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS';
export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL';
+const messages = defineMessages({
+ bookmarkAdded: { id: 'status.bookmarked', defaultMessage: 'Bookmark added.' },
+ bookmarkRemoved: { id: 'status.unbookmarked', defaultMessage: 'Bookmark removed.' },
+});
+
export function reblog(status) {
return function(dispatch, getState) {
if (!isLoggedIn(getState)) return;
@@ -205,28 +211,28 @@ export function unfavouriteFail(status, error) {
};
};
-export function bookmark(status) {
+export function bookmark(intl, status) {
return function(dispatch, getState) {
dispatch(bookmarkRequest(status));
api(getState).post(`/api/v1/statuses/${status.get('id')}/bookmark`).then(function(response) {
dispatch(importFetchedStatus(response.data));
dispatch(bookmarkSuccess(status, response.data));
- dispatch(snackbar.success('Bookmark added'));
+ dispatch(snackbar.success(intl.formatMessage(messages.bookmarkAdded)));
}).catch(function(error) {
dispatch(bookmarkFail(status, error));
});
};
};
-export function unbookmark(status) {
+export function unbookmark(intl, status) {
return (dispatch, getState) => {
dispatch(unbookmarkRequest(status));
api(getState).post(`/api/v1/statuses/${status.get('id')}/unbookmark`).then(response => {
dispatch(importFetchedStatus(response.data));
dispatch(unbookmarkSuccess(status, response.data));
- dispatch(snackbar.success('Bookmark removed'));
+ dispatch(snackbar.success(intl.formatMessage(messages.bookmarkRemoved)));
}).catch(error => {
dispatch(unbookmarkFail(status, error));
});
diff --git a/app/soapbox/components/sidebar_menu.js b/app/soapbox/components/sidebar_menu.js
index ce361134e..7c20b8d2b 100644
--- a/app/soapbox/components/sidebar_menu.js
+++ b/app/soapbox/components/sidebar_menu.js
@@ -70,12 +70,12 @@ const mapStateToProps = state => {
};
};
-const mapDispatchToProps = (dispatch) => ({
+const mapDispatchToProps = (dispatch, { intl }) => ({
onClose() {
dispatch(closeSidebar());
},
onClickLogOut(e) {
- dispatch(logOut());
+ dispatch(logOut(intl));
e.preventDefault();
},
fetchOwnAccounts() {
diff --git a/app/soapbox/containers/status_container.js b/app/soapbox/containers/status_container.js
index 8c5206607..2f4e63287 100644
--- a/app/soapbox/containers/status_container.js
+++ b/app/soapbox/containers/status_container.js
@@ -107,9 +107,9 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
onBookmark(status) {
if (status.get('bookmarked')) {
- dispatch(unbookmark(status));
+ dispatch(unbookmark(intl, status));
} else {
- dispatch(bookmark(status));
+ dispatch(bookmark(intl, status));
}
},
diff --git a/app/soapbox/features/auth_login/components/login_page.js b/app/soapbox/features/auth_login/components/login_page.js
index 9f9b3b8ce..8bd797c52 100644
--- a/app/soapbox/features/auth_login/components/login_page.js
+++ b/app/soapbox/features/auth_login/components/login_page.js
@@ -2,6 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom';
import ImmutablePureComponent from 'react-immutable-pure-component';
+import { injectIntl } from 'react-intl';
import LoginForm from './login_form';
import OtpAuthForm from './otp_auth_form';
import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth';
@@ -12,6 +13,7 @@ const mapStateToProps = state => ({
});
export default @connect(mapStateToProps)
+@injectIntl
class LoginPage extends ImmutablePureComponent {
constructor(props) {
@@ -33,9 +35,9 @@ class LoginPage extends ImmutablePureComponent {
}
handleSubmit = (event) => {
- const { dispatch, me } = this.props;
+ const { dispatch, intl, me } = this.props;
const { username, password } = this.getFormData(event.target);
- dispatch(logIn(username, password)).then(({ access_token }) => {
+ dispatch(logIn(intl, username, password)).then(({ access_token }) => {
return dispatch(verifyCredentials(access_token));
}).then(account => {
this.setState({ shouldRedirect: true });
diff --git a/app/soapbox/features/auth_login/components/password_reset.js b/app/soapbox/features/auth_login/components/password_reset.js
index f7ca59712..ba52ea646 100644
--- a/app/soapbox/features/auth_login/components/password_reset.js
+++ b/app/soapbox/features/auth_login/components/password_reset.js
@@ -1,12 +1,19 @@
import React from 'react';
import { connect } from 'react-redux';
import ImmutablePureComponent from 'react-immutable-pure-component';
+import { defineMessages, FormattedMessage, injectIntl } from 'react-intl';
import { resetPassword } from 'soapbox/actions/auth';
import { SimpleForm, FieldsGroup, TextInput } from 'soapbox/features/forms';
import { Redirect } from 'react-router-dom';
import snackbar from 'soapbox/actions/snackbar';
+const messages = defineMessages({
+ nicknameOrEmail: { id: 'password_reset.fields.username_placeholder', defaultMessage: 'Email or username' },
+ confirmation: { id: 'password_reset.confirmation', defaultMessage: 'Check your email for confirmation.' },
+});
+
export default @connect()
+@injectIntl
class PasswordReset extends ImmutablePureComponent {
state = {
@@ -15,18 +22,20 @@ class PasswordReset extends ImmutablePureComponent {
}
handleSubmit = e => {
- const { dispatch } = this.props;
+ const { dispatch, intl } = this.props;
const nicknameOrEmail = e.target.nickname_or_email.value;
this.setState({ isLoading: true });
dispatch(resetPassword(nicknameOrEmail)).then(() => {
this.setState({ isLoading: false, success: true });
- dispatch(snackbar.info('Check your email for confirmation.'));
+ dispatch(snackbar.info(intl.formatMessage(messages.confirmation)));
}).catch(error => {
this.setState({ isLoading: false });
});
}
render() {
+ const { intl } = this.props;
+
if (this.state.success) return