From 41850c9f14baa5330919c6dabf161b1aaeda7376 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 23 Feb 2022 15:18:37 -0300 Subject: add i18n where was missing --- .../taler-wallet-webextension/src/cta/Deposit.tsx | 75 ++++++++--- packages/taler-wallet-webextension/src/cta/Pay.tsx | 143 ++++++++++++++------- .../taler-wallet-webextension/src/cta/Refund.tsx | 44 +++++-- .../src/cta/TermsOfServiceSection.tsx | 28 ++-- packages/taler-wallet-webextension/src/cta/Tip.tsx | 44 +++++-- .../taler-wallet-webextension/src/cta/Withdraw.tsx | 48 ++++--- .../taler-wallet-webextension/src/cta/payback.tsx | 31 ----- .../src/cta/reset-required.tsx | 33 +++-- .../src/cta/return-coins.tsx | 9 +- 9 files changed, 288 insertions(+), 167 deletions(-) delete mode 100644 packages/taler-wallet-webextension/src/cta/payback.tsx (limited to 'packages/taler-wallet-webextension/src/cta') diff --git a/packages/taler-wallet-webextension/src/cta/Deposit.tsx b/packages/taler-wallet-webextension/src/cta/Deposit.tsx index 39ccdbac0..5adc641f4 100644 --- a/packages/taler-wallet-webextension/src/cta/Deposit.tsx +++ b/packages/taler-wallet-webextension/src/cta/Deposit.tsx @@ -35,6 +35,7 @@ import { NotificationType, PreparePayResult, PreparePayResultType, + Translate, } from "@gnu-taler/taler-util"; import { OperationFailedError } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, VNode } from "preact"; @@ -108,7 +109,11 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode { }, [talerPayUri, foundAmountStr]); if (!talerPayUri) { - return missing pay uri; + return ( + + missing pay uri + + ); } if (!payStatus) { @@ -116,10 +121,16 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode { return ( -

{i18n.str`Digital cash payment`}

+

+ Digital cash payment +

+ Could not get the payment information for this order + + } error={payErrMsg?.operationError} />
@@ -130,15 +141,25 @@ export function DepositPage({ talerPayUri, goBack }: Props): VNode { return ( -

{i18n.str`Digital cash payment`}

+

+ Digital cash payment +

-

Could not get the payment information for this order

+

+ + Could not get the payment information for this order + +

{payErrMsg}
); } - return Loading payment information ...; + return ( + + Loading payment information ... + + ); } const onClick = async (): Promise => { @@ -183,20 +204,32 @@ export function PaymentRequestView({ -

{i18n.str`Digital cash deposit`}

+

+ Digital cash deposit +

{payStatus.status === PreparePayResultType.AlreadyConfirmed && (payStatus.paid ? ( - Already paid + + Already paid + ) : ( - Already claimed + + Already claimed + ))} {payResult && payResult.type === ConfirmPayResultType.Done && ( -

Payment complete

+

+ Payment complete +

- {!payResult.contractTerms.fulfillment_message - ? "You will now be sent back to the merchant you came from." - : payResult.contractTerms.fulfillment_message} + {!payResult.contractTerms.fulfillment_message ? ( + + You will now be sent back to the merchant you came from. + + ) : ( + payResult.contractTerms.fulfillment_message + )}

)} @@ -205,7 +238,7 @@ export function PaymentRequestView({ Amounts.isNonZero(totalFees) && ( Total to pay} text={amountToPretty( Amounts.parseOrThrow(payStatus.amountEffective), )} @@ -214,7 +247,7 @@ export function PaymentRequestView({ )} Purchase amount} text={amountToPretty(Amounts.parseOrThrow(payStatus.amountRaw))} kind="neutral" /> @@ -222,21 +255,25 @@ export function PaymentRequestView({ Fee} text={amountToPretty(totalFees)} kind="negative" /> )} Merchant} text={contractTerms.merchant.name} kind="neutral" /> - + Purchase} + text={contractTerms.summary} + kind="neutral" + /> {contractTerms.order_id && ( Receipt} text={`#${contractTerms.order_id}`} kind="neutral" /> diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 7f5f42e8d..7ed0d072f 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -37,10 +37,12 @@ import { PreparePayResult, PreparePayResultType, Product, + Translate, } from "@gnu-taler/taler-util"; import { OperationFailedError } from "@gnu-taler/taler-wallet-core"; import { Fragment, h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; +import { ErrorMessage } from "../components/ErrorMessage"; import { Loading } from "../components/Loading"; import { LoadingError } from "../components/LoadingError"; import { LogoHeader } from "../components/LogoHeader"; @@ -106,7 +108,12 @@ export function PayPage({ } if (hook.hasError) { - return ; + return ( + Could not load pay status} + error={hook} + /> + ); } const foundBalance = hook.response.balance.balances.find( @@ -178,9 +185,13 @@ export function PaymentRequestView({ if (!contractTerms) { return ( - - Error: did not get contract terms from merchant or wallet backend. - + + Could not load contract terms from merchant or wallet backend. + + } + /> ); } @@ -192,13 +203,6 @@ export function PaymentRequestView({ totalFees = Amounts.sub(amountEffective, amountRaw).amount; } - // let merchantName: VNode; - // if (contractTerms.merchant && contractTerms.merchant.name) { - // merchantName = {contractTerms.merchant.name}; - // } else { - // merchantName = (pub: {contractTerms.merchant_pub}); - // } - function Alternative(): VNode { const [showQR, setShowQR] = useState(false); const privateUri = @@ -209,12 +213,21 @@ export function PaymentRequestView({ return (
setShowQR((qr) => !qr)}> - {!showQR ? i18n.str`Pay with a mobile phone` : i18n.str`Hide QR`} + {!showQR ? ( + Pay with a mobile phone + ) : ( + Hide QR + )} {showQR && (
- Scan the QR code or click here + + Scan the QR code or + + click here + +
)}
@@ -227,7 +240,9 @@ export function PaymentRequestView({ return (
-

Processing...

+

+ Processing... +

); @@ -239,7 +254,9 @@ export function PaymentRequestView({
- {i18n.str`Pay`} {amountToString(payStatus.amountEffective)} + + Pay {amountToString(payStatus.amountEffective)} +
@@ -252,18 +269,22 @@ export function PaymentRequestView({
{balance ? ( - Your balance of {amountToString(balance)} is not enough to pay - for this purchase + + Your balance of {amountToString(balance)} is not enough to pay + for this purchase + ) : ( - Your balance is not enough to pay for this purchase. + + Your balance is not enough to pay for this purchase. + )}
- {i18n.str`Withdraw digital cash`} + Withdraw digital cash
@@ -276,7 +297,7 @@ export function PaymentRequestView({
{payStatus.paid && contractTerms.fulfillment_message && ( Merchant message} text={contractTerms.fulfillment_message} kind="neutral" /> @@ -293,31 +314,48 @@ export function PaymentRequestView({ -

{i18n.str`Digital cash payment`}

+

+ Digital cash payment +

{payStatus.status === PreparePayResultType.AlreadyConfirmed && (payStatus.paid ? ( payStatus.contractTerms.fulfillment_url ? ( - Already paid, you are going to be redirected to{" "} - - {payStatus.contractTerms.fulfillment_url} - + + Already paid, you are going to be redirected to{" "} + + {payStatus.contractTerms.fulfillment_url} + + ) : ( - Already paid + + Already paid + ) ) : ( - Already claimed + + Already claimed + ))} {payResult && payResult.type === ConfirmPayResultType.Done && ( -

Payment complete

+

+ Payment complete +

- {!payResult.contractTerms.fulfillment_message - ? payResult.contractTerms.fulfillment_url - ? `You are going to be redirected to ${payResult.contractTerms.fulfillment_url}` - : "You can close this page." - : payResult.contractTerms.fulfillment_message} + {!payResult.contractTerms.fulfillment_message ? ( + payResult.contractTerms.fulfillment_url ? ( + + You are going to be redirected to $ + {payResult.contractTerms.fulfillment_url} + + ) : ( + You can close this page. + ) + ) : ( + payResult.contractTerms.fulfillment_message + )}

)} @@ -326,14 +364,14 @@ export function PaymentRequestView({ Amounts.isNonZero(totalFees) && ( Total to pay} text={amountToString(payStatus.amountEffective)} kind="negative" /> )} Purchase amount} text={amountToString(payStatus.amountRaw)} kind="neutral" /> @@ -341,21 +379,25 @@ export function PaymentRequestView({ Fee} text={amountToString(totalFees)} kind="negative" /> )} Merchant} text={contractTerms.merchant.name} kind="neutral" /> - + Purchase} + text={contractTerms.summary} + kind="neutral" + /> {contractTerms.order_id && ( Receipt} text={`#${contractTerms.order_id}`} kind="neutral" /> @@ -373,7 +415,7 @@ function ProductList({ products }: { products: Product[] }): VNode { return ( - List of products + List of products
{products.map((p, i) => { @@ -415,15 +457,18 @@ function ProductList({ products }: { products: Product[] }): VNode { {p.quantity ?? 1} x {p.description}
- Total{` `} - {p.price - ? `${Amounts.stringifyValue( - Amounts.mult( - Amounts.parseOrThrow(p.price), - p.quantity ?? 1, - ).amount, - )} ${p}` - : "free"} + Total + {` `} + {p.price ? ( + `${Amounts.stringifyValue( + Amounts.mult( + Amounts.parseOrThrow(p.price), + p.quantity ?? 1, + ).amount, + )} ${p}` + ) : ( + free + )}
diff --git a/packages/taler-wallet-webextension/src/cta/Refund.tsx b/packages/taler-wallet-webextension/src/cta/Refund.tsx index cecd1ac00..ec32cc37a 100644 --- a/packages/taler-wallet-webextension/src/cta/Refund.tsx +++ b/packages/taler-wallet-webextension/src/cta/Refund.tsx @@ -17,10 +17,10 @@ /** * Page that shows refund status for purchases. * - * @author Florian Dold + * @author sebasjm */ -import { Amounts, ApplyRefundResponse } from "@gnu-taler/taler-util"; +import { Amounts, ApplyRefundResponse, Translate } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; import { AmountView } from "../renderHtml"; @@ -37,20 +37,28 @@ export function View({ applyResult }: ViewProps): VNode {

GNU Taler Wallet

-

Refund Status

+

+ Refund Status +

- The product {applyResult.info.summary} has received a total - effective refund of{" "} + + The product {applyResult.info.summary} has received a total + effective refund of{" "} + .

{applyResult.pendingAtExchange ? ( -

Refund processing is still in progress.

+

+ Refund processing is still in progress. +

) : null} {!Amounts.isZero(applyResult.amountRefundGone) ? (

- The refund amount of{" "} - could not be - applied. + + The refund amount of{" "} + could not be + applied. +

) : null}
@@ -82,15 +90,27 @@ export function RefundPage({ talerRefundUri }: Props): VNode { console.log("rendering"); if (!talerRefundUri) { - return missing taler refund uri; + return ( + + missing taler refund uri + + ); } if (errMsg) { - return Error: {errMsg}; + return ( + + Error: {errMsg} + + ); } if (!applyResult) { - return Updating refund status; + return ( + + Updating refund status + + ); } return ; diff --git a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx index 584da6d29..00f7bd211 100644 --- a/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx +++ b/packages/taler-wallet-webextension/src/cta/TermsOfServiceSection.tsx @@ -1,4 +1,4 @@ -import { i18n } from "@gnu-taler/taler-util"; +import { i18n, Translate } from "@gnu-taler/taler-util"; import { Fragment, h, VNode } from "preact"; import { CheckboxOutlined } from "../components/CheckboxOutlined"; import { ExchangeXmlTos } from "../components/ExchangeToS"; @@ -34,7 +34,7 @@ export function TermsOfServiceSection({ {terms.status === "notfound" && (
- {i18n.str`Exchange doesn't have terms of service`} + Exchange doesn't have terms of service
)} @@ -46,21 +46,21 @@ export function TermsOfServiceSection({ {terms.status === "notfound" && (
- {i18n.str`Exchange doesn't have terms of service`} + Exchange doesn't have terms of service
)} {terms.status === "new" && (
onReview(true)}> - {i18n.str`Review exchange terms of service`} + Review exchange terms of service
)} {terms.status === "changed" && (
onReview(true)}> - {i18n.str`Review new version of terms of service`} + Review new version of terms of service
)} @@ -72,7 +72,7 @@ export function TermsOfServiceSection({ {onReview && (
onReview(true)}> - {i18n.str`Show terms of service`} + Show terms of service
)} @@ -80,7 +80,9 @@ export function TermsOfServiceSection({ I accept the exchange terms of service + } onToggle={() => { onAccept(!reviewed); if (onReview) onReview(false); @@ -95,7 +97,9 @@ export function TermsOfServiceSection({ {terms.status !== "notfound" && !terms.content && (
- The exchange reply with a empty terms of service + + The exchange reply with a empty terms of service +
)} @@ -116,7 +120,7 @@ export function TermsOfServiceSection({ )} {terms.content.type === "pdf" && ( - Download Terms of Service + Download Terms of Service )}
@@ -124,7 +128,7 @@ export function TermsOfServiceSection({ {reviewed && onReview && (
onReview(false)}> - {i18n.str`Hide terms of service`} + Hide terms of service
)} @@ -133,7 +137,9 @@ export function TermsOfServiceSection({ I accept the exchange terms of service + } onToggle={() => { onAccept(!reviewed); if (onReview) onReview(false); diff --git a/packages/taler-wallet-webextension/src/cta/Tip.tsx b/packages/taler-wallet-webextension/src/cta/Tip.tsx index 3f8b09bd1..9bb03b7ac 100644 --- a/packages/taler-wallet-webextension/src/cta/Tip.tsx +++ b/packages/taler-wallet-webextension/src/cta/Tip.tsx @@ -17,10 +17,10 @@ /** * Page shown to the user to accept or ignore a tip from a merchant. * - * @author Florian Dold + * @author sebasjm */ -import { PrepareTipResult } from "@gnu-taler/taler-util"; +import { PrepareTipResult, Translate } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { useEffect, useState } from "preact/hooks"; import { Loading } from "../components/Loading"; @@ -46,21 +46,29 @@ export function View({
{prepareTipResult.accepted ? ( - Tip from {prepareTipResult.merchantBaseUrl} accepted. - Check your transactions list for more details. + + Tip from {prepareTipResult.merchantBaseUrl} accepted. + Check your transactions list for more details. + ) : (

- The merchant {prepareTipResult.merchantBaseUrl} is - offering you a tip of{" "} - - - {" "} - via the exchange {prepareTipResult.exchangeBaseUrl} + + The merchant {prepareTipResult.merchantBaseUrl} is + offering you a tip of{" "} + + + {" "} + via the exchange {prepareTipResult.exchangeBaseUrl} +

- - + +
)}
@@ -98,11 +106,19 @@ export function TipPage({ talerTipUri }: Props): VNode { }; if (!talerTipUri) { - return missing tip uri; + return ( + + missing tip uri + + ); } if (tipIgnored) { - return You've ignored the tip.; + return ( + + You've ignored the tip. + + ); } if (!prepareTipResult) { diff --git a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx index 8f45a047c..7d36a6084 100644 --- a/packages/taler-wallet-webextension/src/cta/Withdraw.tsx +++ b/packages/taler-wallet-webextension/src/cta/Withdraw.tsx @@ -18,7 +18,7 @@ * Page shown to the user to confirm creation * of a reserve, usually requested by the bank. * - * @author Florian Dold + * @author sebasjm */ import { @@ -26,6 +26,7 @@ import { Amounts, ExchangeListItem, i18n, + Translate, WithdrawUriInfoResponse, } from "@gnu-taler/taler-util"; import { OperationFailedError } from "@gnu-taler/taler-wallet-core"; @@ -117,37 +118,46 @@ export function View({ return ( -

{i18n.str`Digital cash withdrawal`}

+

+ Digital cash withdrawal +

{withdrawError && ( Could not finish the withdrawal operation + } error={withdrawError.operationError} /> )}
Total to withdraw} text={amountToString(Amounts.sub(amount, withdrawalFee).amount)} kind="positive" /> {Amounts.isNonZero(withdrawalFee) && ( Chosen amount} text={amountToString(amount)} kind="neutral" /> Exchange fee} text={amountToString(withdrawalFee)} kind="negative" /> )} {exchangeBaseUrl && ( - + Exchange} + text={exchangeBaseUrl} + kind="neutral" + big + /> )}
{!reviewing && ( @@ -156,7 +166,7 @@ export function View({
Known exchanges} list={exchanges} value={nextExchange} name="switchingExchange" @@ -172,14 +182,16 @@ export function View({ setSwitchingExchange(false); }} > - {nextExchange === undefined - ? i18n.str`Cancel exchange selection` - : i18n.str`Confirm exchange selection`} + {nextExchange === undefined ? ( + Cancel exchange selection + ) : ( + Confirm exchange selection + )} ) : ( setSwitchingExchange(true)}> - {i18n.str`Switch exchange`} + Switch exchange )}
@@ -198,7 +210,7 @@ export function View({ disabled={!exchangeBaseUrl || confirmDisabled} onClick={doWithdrawAndCheckError} > - {i18n.str`Confirm withdrawal`} + Confirm withdrawal )} {terms.status === "notfound" && ( @@ -207,7 +219,7 @@ export function View({ disabled={!exchangeBaseUrl} onClick={doWithdrawAndCheckError} > - {i18n.str`Withdraw anyway`} + Withdraw anyway )} @@ -270,7 +282,7 @@ export function WithdrawPageWithParsedURI({ if (detailsHook.hasError) { return ( Could not load the withdrawal details} error={detailsHook} /> ); @@ -293,9 +305,7 @@ export function WithdrawPageWithParsedURI({ const onWithdraw = async (): Promise => { if (!exchange) return; - console.log("accepting exchange", exchange); const res = await wxApi.acceptWithdrawal(uri, exchange); - console.log("accept withdrawal response", res); if (res.confirmTransferUrl) { document.location.href = res.confirmTransferUrl; } @@ -327,7 +337,7 @@ export function WithdrawPage({ talerWithdrawUri }: Props): VNode { if (!talerWithdrawUri) { return ( - missing withdraw uri + missing withdraw uri ); } @@ -337,7 +347,7 @@ export function WithdrawPage({ talerWithdrawUri }: Props): VNode { if (uriInfoHook.hasError) { return ( Could not get the info from the URI} error={uriInfoHook} /> ); diff --git a/packages/taler-wallet-webextension/src/cta/payback.tsx b/packages/taler-wallet-webextension/src/cta/payback.tsx deleted file mode 100644 index 1c81b48a0..000000000 --- a/packages/taler-wallet-webextension/src/cta/payback.tsx +++ /dev/null @@ -1,31 +0,0 @@ -/* - This file is part of TALER - (C) 2017 Inria - - TALER is free software; you can redistribute it and/or modify it under the - terms of the GNU General Public License as published by the Free Software - Foundation; either version 3, or (at your option) any later version. - - TALER is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along with - TALER; see the file COPYING. If not, see - */ - -import { h, VNode } from "preact"; - -/** - * View and edit auditors. - * - * @author Florian Dold - */ - -/** - * Imports. - */ - -export function makePaybackPage(): VNode { - return
not implemented
; -} diff --git a/packages/taler-wallet-webextension/src/cta/reset-required.tsx b/packages/taler-wallet-webextension/src/cta/reset-required.tsx index 75c4c1962..e8c5a0dff 100644 --- a/packages/taler-wallet-webextension/src/cta/reset-required.tsx +++ b/packages/taler-wallet-webextension/src/cta/reset-required.tsx @@ -17,9 +17,10 @@ /** * Page to inform the user when a database reset is required. * - * @author Florian Dold + * @author sebasjm */ +import { Translate } from "@gnu-taler/taler-util"; import { Component, h, VNode } from "preact"; import * as wxApi from "../wxApi"; @@ -49,14 +50,20 @@ class ResetNotification extends Component { if (this.state.resetRequired) { return (
-

Manual Reset Required

+

+ Manual Reset Required +

- The wallet's database in your browser is incompatible with the{" "} - currently installed wallet. Please reset manually. + + The wallet's database in your browser is incompatible with + the currently installed wallet. Please reset manually. +

- Once the database format has stabilized, we will provide automatic - upgrades. + + Once the database format has stabilized, we will provide automatic + upgrades. +

{ }} />{" "}
); } return (
-

Everything is fine!

A reset is not required anymore, you can - close this page. +

+ Everything is fine! +

+

+ + A reset is not required anymore, you can close this page. + +

); } diff --git a/packages/taler-wallet-webextension/src/cta/return-coins.tsx b/packages/taler-wallet-webextension/src/cta/return-coins.tsx index 55f0297d4..22b373899 100644 --- a/packages/taler-wallet-webextension/src/cta/return-coins.tsx +++ b/packages/taler-wallet-webextension/src/cta/return-coins.tsx @@ -14,16 +14,21 @@ TALER; see the file COPYING. If not, see */ +import { Translate } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; /** * Return coins to own bank account. * - * @author Florian Dold + * @author sebasjm */ /** * Imports. */ export function createReturnCoinsPage(): VNode { - return Not implemented yet.; + return ( + + Not implemented yet. + + ); } -- cgit v1.2.3