1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00

l10n for actions that use notifications

This commit is contained in:
slowbackspace 2019-04-29 18:49:16 +02:00
parent 3bcf991ef9
commit 25e8c6ae56
13 changed files with 133 additions and 33 deletions

View File

@ -1,5 +1,6 @@
/* @flow */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import TrezorConnect, { UI } from 'trezor-connect';
import * as BLOCKCHAIN_ACTION from 'actions/constants/blockchain';
import * as DISCOVERY from 'actions/constants/discovery';
@ -17,6 +18,8 @@ import type {
Account,
} from 'flowtype';
import type { Discovery, State } from 'reducers/DiscoveryReducer';
import l10nMessages from 'components/notifications/Context/actions.messages';
import l10nCommonMessages from 'views/common.messages';
import * as BlockchainActions from './BlockchainActions';
import * as EthereumDiscoveryActions from './ethereum/DiscoveryActions';
import * as RippleDiscoveryActions from './ripple/DiscoveryActions';
@ -176,12 +179,12 @@ const begin = (device: TrezorDevice, networkName: string): AsyncAction => async
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Discovery error',
title: <FormattedMessage {...l10nMessages.TR_ACCOUNT_DISCOVERY_ERROR} />,
message: error.message,
cancelable: true,
actions: [
{
label: 'Try again',
label: <FormattedMessage {...l10nCommonMessages.TR_TRY_AGAIN} />,
callback: () => {
dispatch(start(device, networkName));
},
@ -264,12 +267,12 @@ const discoverAccount = (device: TrezorDevice, discoveryProcess: Discovery): Asy
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Account discovery error',
title: <FormattedMessage {...l10nMessages.TR_ACCOUNT_DISCOVERY_ERROR} />,
message: error.message,
cancelable: true,
actions: [
{
label: 'Try again',
label: <FormattedMessage {...l10nCommonMessages.TR_TRY_AGAIN} />,
callback: () => {
dispatch(start(device, discoveryProcess.network));
},

View File

@ -2,7 +2,14 @@
import * as React from 'react';
import * as NOTIFICATION from 'actions/constants/notification';
import type { Action, AsyncAction, GetState, Dispatch, RouterLocationState } from 'flowtype';
import type {
Action,
AsyncAction,
GetState,
Dispatch,
RouterLocationState,
MessageDescriptor,
} from 'flowtype';
import type { CallbackAction } from 'reducers/NotificationReducer';
export type NotificationAction =
@ -10,7 +17,7 @@ export type NotificationAction =
type: typeof NOTIFICATION.ADD,
payload: {
+type: string,
+title: React.Node | string,
+title: React.Node | MessageDescriptor | string,
+message?: ?(React.Node | string),
+cancelable: boolean,
actions?: Array<CallbackAction>,

View File

@ -1,5 +1,6 @@
/* @flow */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import TrezorConnect from 'trezor-connect';
import * as RECEIVE from 'actions/constants/receive';
import * as NOTIFICATION from 'actions/constants/notification';
@ -8,6 +9,8 @@ import { initialState } from 'reducers/ReceiveReducer';
import type { State } from 'reducers/ReceiveReducer';
import type { TrezorDevice, ThunkAction, AsyncAction, Action, GetState, Dispatch } from 'flowtype';
import l10nMessages from 'components/notifications/Context/actions.messages';
import l10nCommonMessages from 'views/common.messages';
export type ReceiveAction =
| {
@ -112,12 +115,12 @@ export const showAddress = (path: Array<number>): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Verifying address error',
title: <FormattedMessage {...l10nMessages.TR_VERIFYING_ADDRESS_ERROR} />,
message: response.payload.error,
cancelable: true,
actions: [
{
label: 'Try again',
label: <FormattedMessage {...l10nCommonMessages.TR_TRY_AGAIN} />,
callback: () => {
dispatch(showAddress(path));
},

View File

@ -1,8 +1,11 @@
/* @flow */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import TrezorConnect from 'trezor-connect';
import type { GetState, Dispatch, ThunkAction, AsyncAction } from 'flowtype';
import { validateAddress } from 'utils/ethUtils';
import * as NOTIFICATION from 'actions/constants/notification';
import l10nMessages from 'components/notifications/Context/actions.messages';
import * as SIGN_VERIFY from './constants/signVerify';
export type SignVerifyAction =
@ -65,7 +68,7 @@ const sign = (path: Array<number>, message: string, hex: boolean = false): Async
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Sign error',
title: <FormattedMessage {...l10nMessages.TR_SIGN_MESSAGE_ERROR} />,
message: response.payload.error,
cancelable: true,
},
@ -110,8 +113,8 @@ const verify = (
type: NOTIFICATION.ADD,
payload: {
type: 'success',
title: 'Verify success',
message: 'signature is valid',
title: <FormattedMessage {...l10nMessages.TR_VERIFY_MESSAGE_SUCCESS} />,
message: <FormattedMessage {...l10nMessages.TR_SIGNATURE_IS_VALID} />,
cancelable: true,
},
});
@ -120,7 +123,7 @@ const verify = (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Verify error',
title: <FormattedMessage {...l10nMessages.TR_VERIFY_MESSAGE_ERROR} />,
message: response.payload.error,
cancelable: true,
},

View File

@ -6,6 +6,8 @@ import TrezorConnect, {
TRANSPORT_EVENT,
BLOCKCHAIN_EVENT,
} from 'trezor-connect';
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { CONTEXT_NONE } from 'actions/constants/modal';
import urlConstants from 'constants/urls';
import * as CONNECT from 'actions/constants/TrezorConnect';
@ -35,6 +37,9 @@ import type {
TrezorDevice,
} from 'flowtype';
import l10nCommonMessages from 'views/common.messages';
import l10nMessages from 'components/notifications/Context/actions.messages';
export type TrezorConnectAction =
| {
type: typeof CONNECT.INITIALIZATION_ERROR,
@ -264,12 +269,12 @@ export const authorizeDevice = (): AsyncAction => async (
payload: {
devicePath: selected.path,
type: 'error',
title: 'Authentication error',
title: <FormattedMessage {...l10nMessages.TR_AUTHENTICATION_ERROR} />,
message: response.payload.error,
cancelable: false,
actions: [
{
label: 'Try again',
label: <FormattedMessage {...l10nCommonMessages.TR_TRY_AGAIN} />,
callback: () => {
dispatch({
type: NOTIFICATION.CLOSE,
@ -350,7 +355,7 @@ export function acquire(): AsyncAction {
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Acquire device error',
title: <FormattedMessage {...l10nMessages.TR_ACQUIRE_DEVICE_ERROR} />,
message: response.payload.error,
cancelable: true,
// actions: [

View File

@ -1,5 +1,6 @@
/* @flow */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { Link } from 'trezor-ui-components';
import TrezorConnect from 'trezor-connect';
import BigNumber from 'bignumber.js';
@ -23,10 +24,10 @@ import type {
TrezorDevice,
} from 'flowtype';
import type { State, FeeLevel } from 'reducers/SendFormEthereumReducer';
import l10nMessages from 'components/notifications/Context/actions.messages';
import * as SessionStorageActions from '../SessionStorageActions';
import { prepareEthereumTx, serializeEthereumTx } from '../TxActions';
import * as BlockchainActions from './BlockchainActions';
import * as ValidationActions from './SendFormValidationActions';
// list of all actions which has influence on "sendFormEthereum" reducer
@ -717,7 +718,7 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Transaction error',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_ERROR} />,
message: signedTransaction.payload.error,
cancelable: true,
actions: [],
@ -807,10 +808,10 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'success',
title: 'Transaction success',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_SUCCESS} />,
message: (
<Link href={`${network.explorer.tx}${txid}`} isGreen>
See transaction detail
<FormattedMessage {...l10nMessages.TR_SEE_TRANSACTION_DETAILS} />
</Link>
),
cancelable: true,
@ -822,7 +823,7 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Transaction error',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_ERROR} />,
message: error.message || error,
cancelable: true,
actions: [],

View File

@ -1,4 +1,6 @@
/* @flow */
import React from 'react';
import { FormattedMessage } from 'react-intl';
import TrezorConnect from 'trezor-connect';
import * as NOTIFICATION from 'actions/constants/notification';
import * as SEND from 'actions/constants/send';
@ -19,6 +21,7 @@ import type {
TrezorDevice,
} from 'flowtype';
import type { State, FeeLevel } from 'reducers/SendFormRippleReducer';
import l10nMessages from 'components/notifications/Context/actions.messages';
import * as SessionStorageActions from '../SessionStorageActions';
import * as BlockchainActions from './BlockchainActions';
@ -455,7 +458,7 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Transaction error',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_ERROR} />,
message: signedTransaction.payload.error,
cancelable: true,
actions: [],
@ -474,7 +477,7 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'error',
title: 'Transaction error',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_ERROR} />,
message: push.payload.error,
cancelable: true,
actions: [],
@ -497,7 +500,7 @@ export const onSend = (): AsyncAction => async (
type: NOTIFICATION.ADD,
payload: {
type: 'success',
title: 'Transaction success',
title: <FormattedMessage {...l10nMessages.TR_TRANSACTION_SUCCESS} />,
message: txid,
cancelable: true,
actions: [],

View File

@ -159,7 +159,7 @@ class ConfirmUnverifiedAddress extends PureComponent<Props> {
<Content>
<Row>
<Button onClick={() => (!account ? this.verifyAddress() : 'false')}>
<FormattedMessage {...l10nMessages.TR_TRY_AGAIN} />
<FormattedMessage {...l10nCommonMessages.TR_TRY_AGAIN} />
</Button>
<WarnButton isWhite onClick={() => this.showUnverifiedAddress()}>
<FormattedMessage {...l10nMessages.TR_SHOW_UNVERIFIED_ADDRESS} />

View File

@ -33,11 +33,6 @@ const definedMessages: Messages = defineMessages({
id: 'TR_SHOW_UNVERIFIED_ADDRESS',
defaultMessage: 'Show unverified address',
},
TR_TRY_AGAIN: {
id: 'TR_TRY_AGAIN',
defaultMessage: 'Try again',
description: 'Try to verify the address again',
},
TR_TO_PREVENT_PHISHING_ATTACKS_COMMA: {
id: 'TR_TO_PREVENT_PHISHING_ATTACKS_COMMA',
defaultMessage:

View File

@ -0,0 +1,54 @@
/* @flow */
import { defineMessages } from 'react-intl';
import type { Messages } from 'flowtype';
const definedMessages: Messages = defineMessages({
TR_ACQUIRE_DEVICE_ERROR: {
id: 'TR_ACQUIRE_DEVICE_ERROR',
defaultMessage: 'Acquire device error',
},
TR_AUTHENTICATION_ERROR: {
id: 'TR_AUTHENTICATION_ERROR',
defaultMessage: 'Authentication error',
},
TR_ACCOUNT_DISCOVERY_ERROR: {
id: 'TR_ACCOUNT_DISCOVERY_ERROR',
defaultMessage: 'Account discovery error',
description: 'Error during account discovery',
},
TR_TRANSACTION_ERROR: {
id: 'TR_TRANSACTION_ERROR',
defaultMessage: 'Transaction error',
description: 'Error during signing transaction',
},
TR_TRANSACTION_SUCCESS: {
id: 'TR_TRANSACTION_SUCCESS',
defaultMessage: 'Transaction has been sent successfully',
},
TR_SEE_TRANSACTION_DETAILS: {
id: 'TR_SEE_TRANSACTION_DETAILS',
defaultMessage: 'See transaction details',
},
TR_VERIFYING_ADDRESS_ERROR: {
id: 'TR_VERIFYING_ADDRESS_ERROR',
defaultMessage: 'Verifying address error',
},
TR_SIGN_MESSAGE_ERROR: {
id: 'TR_SIGN_MESSAGE_ERROR',
defaultMessage: 'Sign error',
},
TR_VERIFY_MESSAGE_ERROR: {
id: 'TR_VERIFY_MESSAGE_ERROR',
defaultMessage: 'Verify error',
},
TR_VERIFY_MESSAGE_SUCCESS: {
id: 'TR_VERIFY_MESSAGE_SUCCESS',
defaultMessage: 'Message has been successfully verified',
},
TR_SIGNATURE_IS_VALID: {
id: 'TR_SIGNATURE_IS_VALID',
defaultMessage: 'Signature is valid',
},
});
export default definedMessages;

View File

@ -41,6 +41,18 @@ const StyledIcon = styled(Icon)`
margin-right: 6px;
`;
// const getLocalizedMessage = msg => {
// if (
// typeof msg === 'object' &&
// msg.hasOwnProperty('id') &&
// msg.hasOwnProperty('defaultMessage')
// ) {
// //messageDescriptor
// return <FormattedMessage {...msg} />;
// }
// return msg;
// };
class Group extends PureComponent {
constructor() {
super();
@ -114,7 +126,16 @@ Group.propTypes = {
PropTypes.shape({
key: PropTypes.object,
type: PropTypes.string,
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
title: PropTypes.oneOfType([
PropTypes.string,
PropTypes.node,
PropTypes.shape({
id: PropTypes.string,
defaultMessage: PropTypes.string,
description: PropTypes.string,
values: PropTypes.object,
}),
]),
message: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
})
),

View File

@ -8,7 +8,7 @@ import { DEVICE } from 'trezor-connect';
import type { Action } from 'flowtype';
export type CallbackAction = {
label: string,
label: React.Node,
callback: Function,
};

View File

@ -131,6 +131,11 @@ const definedMessages: Messages = defineMessages({
defaultMessage: 'Custom',
description: 'fee level',
},
TR_TRY_AGAIN: {
id: 'TR_TRY_AGAIN',
defaultMessage: 'Try again',
description: 'Try to run the proccess again',
},
});
export default definedMessages;