From 3396b0c8de5f4a71e181d909eb14c8012bfab149 Mon Sep 17 00:00:00 2001 From: Nicola Benaglia Date: Fri, 23 May 2025 16:22:14 +0200 Subject: [PATCH] Add translations --- src/i18n/locales/en/question.json | 8 +++++ src/qortalRequests/get.ts | 60 +++++++++++++++++++++++++------ 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/i18n/locales/en/question.json b/src/i18n/locales/en/question.json index fc0d9f3..3671c17 100644 --- a/src/i18n/locales/en/question.json +++ b/src/i18n/locales/en/question.json @@ -5,6 +5,7 @@ "always_retrieve_balance": "always allow balance to be retrieved automatically", "always_retrieve_list": "always allow lists to be retrieved automatically", "always_retrieve_wallet": "always allow wallet to be retrieved automatically", + "always_retrieve_wallet_transactions": "always allow wallet transactions to be retrieved automatically", "amount_qty": "amount: {{ quantity }}", "asset_name": "asset: {{ asset }}", "assets_used_pay": "asset used in payments: {{ asset }}", @@ -33,6 +34,8 @@ "fetch_poll": "failed to fetch poll", "fetch_recipient_public_key": "failed to fetch recipient's public key", "fetch_wallet": "fetch Wallet Failed. Please try again", + "fetch_wallet_info": "unable to fetch wallet information", + "fetch_wallet_transactions": "unable to fetch wallet transactions", "file_extension": "a file extension could not be derived", "gateway_balance_local_node": "cannot view {{ token }} balance through the gateway. Please use your local node.", "gateway_non_qort_local_node": "cannot send a non-QORT coin through the gateway. Please use your local node.", @@ -74,6 +77,7 @@ "synchronization_attempts": "failed to synchronize after {{ quantity }} attempts", "timeout_request": "request timed out", "token_not_supported": "{{ token }} is not supported for this call", + "transaction_activity_summary": "error in transaction activity summary", "unknown_error": "unknown error", "update_foreign_fee": "failed to update foreign fee", "update_tradebot": "unable to update tradebot", @@ -83,6 +87,7 @@ "user_qortal_name": "user has no Qortal name" }, "generic": { + "calculate_fee": "*the {{ amount }} sats fee is derived from {{ rate }} sats per kb, for a transaction that is approximately 300 bytes in size.", "confirm_join_group": "confirm joining the group:", "include_data_decrypt": "please include data to decrypt", "include_data_encrypt": "please include data to encrypt", @@ -125,11 +130,14 @@ "permission_send_coins": "do you give this application permission to send coins?", "permission_transfer_asset": "do you give this application permission to transfer the following asset?", "permission_get_wallet_info": "do you give this application permission to get your wallet information?", + "permission_get_wallet_transactions": "do you give this application permission to retrieve your wallet transactions", "permission_send_chat_message": "do you give this application permission to send this chat message?", "poll": "poll: {{ name }}", "provide_recipient_group_id": "please provide a recipient or groupId", "request_create_poll": "you are requesting to create the poll below:", "request_vote_poll": "you are being requested to vote on the poll below:", + "sats": "{{ amount }} sats", + "sats_per_kb": "{{ amount }} sats per KB", "to_group": "to: group {{ group_id }}", "to_recipient": "to: {{ recipient }}", "total_locking_fee": "total Locking Fee:", diff --git a/src/qortalRequests/get.ts b/src/qortalRequests/get.ts index e137770..4a45593 100644 --- a/src/qortalRequests/get.ts +++ b/src/qortalRequests/get.ts @@ -2925,7 +2925,12 @@ export const getUserWalletInfo = async (data, isFromExtension, appInfo) => { }, body: JSON.stringify(_body), }); - if (!response?.ok) throw new Error('Unable to fetch wallet information'); + if (!response?.ok) + throw new Error( + i18n.t('question:message.error.fetch_wallet_info', { + postProcess: 'capitalizeFirstChar', + }) + ); let res; try { res = await response.clone().json(); @@ -2938,7 +2943,12 @@ export const getUserWalletInfo = async (data, isFromExtension, appInfo) => { return res; } catch (error) { - throw new Error(error?.message || 'Fetch Wallet Failed'); + throw new Error( + error?.message || + i18n.t('question:message.error.fetch_wallet', { + postProcess: 'capitalizeFirstChar', + }) + ); } } else { throw new Error( @@ -2983,12 +2993,15 @@ export const getUserWalletTransactions = async ( if (!skip) { resPermission = await getUserPermission( { - text1: - 'Do you give this application permission to retrieve your wallet transactions', + text1: i18n.t('question:permission_get_wallet_transactions', { + postProcess: 'capitalizeFirstChar', + }), highlightedText: `coin: ${data.coin}`, checkbox1: { value: true, - label: 'Always allow wallet txs to be retrieved automatically', + label: i18n.t('question:always_retrieve_wallet_transactions', { + postProcess: 'capitalizeFirstChar', + }), }, }, isFromExtension @@ -3028,7 +3041,12 @@ export const getUserWalletTransactions = async ( }, body: _body, }); - if (!response?.ok) throw new Error('Unable to fetch wallet transactions'); + if (!response?.ok) + throw new Error( + i18n.t('question:message.error.fetch_wallet_transactions', { + postProcess: 'capitalizeFirstChar', + }) + ); let res; try { res = await response.clone().json(); @@ -3041,7 +3059,12 @@ export const getUserWalletTransactions = async ( return res; } catch (error) { - throw new Error(error?.message || 'Fetch Wallet Transactions Failed'); + throw new Error( + error?.message || + i18n.t('question:message.error.fetch_wallet_transactions', { + postProcess: 'capitalizeFirstChar', + }) + ); } } else { throw new Error( @@ -3146,7 +3169,12 @@ export const getTxActivitySummary = async (data) => { } return res; // Return full response here } catch (error) { - throw new Error(error?.message || 'Error in tx activity summary'); + throw new Error( + error?.message || + i18n.t('question:message.error.transaction_activity_summary', { + postProcess: 'capitalizeFirstChar', + }) + ); } }; @@ -3243,10 +3271,22 @@ export const updateForeignFee = async (data, isFromExtension) => { const { coin, type, value } = data; const text3 = - type === 'feerequired' ? `${value} sats` : `${value} sats per kb`; + type === 'feerequired' + ? i18n.t('question:sats', { + amount: value, + postProcess: 'capitalizeFirstChar', + }) + : i18n.t('question:sats_per_kb', { + amount: value, + postProcess: 'capitalizeFirstChar', + }); const text4 = type === 'feerequired' - ? `*The ${value} sats fee is derived from ${calculateRateFromFee(value, 300)} sats per kb, for a transaction that is approximately 300 bytes in size.` + ? i18n.t('question:message.generic.calculate_fee', { + amount: value, + rate: calculateRateFromFee(value, 300), + postProcess: 'capitalizeFirstChar', + }) : ''; const resPermission = await getUserPermission( {