Skip to content

Commit

Permalink
Merge pull request #3866 from Emurgo/fix/send-error-i18n
Browse files Browse the repository at this point in the history
internationalize send error message
  • Loading branch information
vsubhuman authored Feb 24, 2025
2 parents 6c18ff2 + 7444948 commit 2dfe3de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ const messages = defineMessages({
id: 'wallet.send.trezor.confirmationDialog.submit',
defaultMessage: '!!!Send using Trezor',
},
transactionErrorTitle: {
id: 'wallet.send.error.title.transactionError',
defaultMessage: '!!!Transaction Error',
},
transactionErrorMnemonic: {
id: 'wallet.send.error.description.mnemonic',
defaultMessage: '!!!The transaction cannot be done due to technical reasons. Try again or <link>ask our support team</link>',
},
});

@observer
Expand Down Expand Up @@ -387,13 +395,25 @@ export default class WalletSendPreviewStep extends Component<Props, State> {
renderError(): Node {
const { walletType } = this.props;
const { intl } = this.context;
const txErrorTitle = intl.formatMessage(messages.transactionErrorTitle);
if (walletType === 'mnemonic') {
const { txError } = this.state;
if (txError !== null) {
const re = /(.*)<link>(.*)<\/link>(.*)/;
let m = intl.formatMessage(messages.transactionErrorMnemonic).match(re);
if (!m) {
// the translation has an error, fall back
m = [
undefined,
'The transaction cannot be done due to technical reasons. Try again or ',
'ask our support team',
''
];
}
return this.renderErrorBanner(
'Transaction error',
txErrorTitle,
<div>
The transaction cannot be done due to technical reasons. Try again or
{m[1]}
<Link
className={styles.faq}
href="https://emurgohelpdesk.zendesk.com/hc/en-us/categories/4412619927695-Yoroi"
Expand All @@ -404,8 +424,9 @@ export default class WalletSendPreviewStep extends Component<Props, State> {
marginLeft: '4px',
}}
>
Ask our support team
{m[2]}
</Link>
{m[3]}
</div>
);
}
Expand All @@ -414,14 +435,14 @@ export default class WalletSendPreviewStep extends Component<Props, State> {
if (walletType === 'trezor') {
const { trezorSendError } = this.props;
if (trezorSendError !== null) {
return this.renderErrorBanner('Transaction error', intl.formatMessage(trezorSendError));
return this.renderErrorBanner(txErrorTitle, intl.formatMessage(trezorSendError));
}
return null;
}
if (walletType === 'ledger') {
const { ledgerSendError } = this.props;
if (ledgerSendError !== null) {
return this.renderErrorBanner('Transaction error', intl.formatMessage(ledgerSendError));
return this.renderErrorBanner(txErrorTitle, intl.formatMessage(ledgerSendError));
}
return null;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/yoroi-extension/app/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,8 @@
"wallet.send.confirmationDialog.txSizeLabel": "Size (bytes)",
"wallet.send.confirmationDialog.walletPasswordFieldPlaceholder": "Type your password",
"wallet.send.confirmationDialog.walletPasswordLabel": "Password",
"wallet.send.error.description.mnemonic": "The transaction cannot be done due to technical reasons. Try again or <link>ask our support team</link>",
"wallet.send.error.title.transactionError": "Transaction Error",
"wallet.send.form.addAssets": "Add assets",
"wallet.send.form.amount.minimumRequiredADA": "Minimum required is {number} ADA",
"wallet.send.form.calculatingFee": "Calculating the fee, please wait.",
Expand Down

0 comments on commit 2dfe3de

Please sign in to comment.