From 08959f83bc9f6d5df93cb6c2d34b671bf419d05a Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 14 Mar 2022 15:20:32 -0300 Subject: take translator from transaltion context --- .../src/popup/BalancePage.tsx | 4 +++- .../src/popup/DeveloperPage.tsx | 22 ++++++++++++++-------- .../src/popup/NoBalanceHelp.tsx | 3 ++- .../src/popup/TalerActionFound.tsx | 4 +++- 4 files changed, 22 insertions(+), 11 deletions(-) (limited to 'packages/taler-wallet-webextension/src/popup') diff --git a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx index 53b4e1518..c894c333f 100644 --- a/packages/taler-wallet-webextension/src/popup/BalancePage.tsx +++ b/packages/taler-wallet-webextension/src/popup/BalancePage.tsx @@ -17,7 +17,6 @@ import { Amounts, Balance, - i18n, NotificationType, Transaction, } from "@gnu-taler/taler-util"; @@ -29,6 +28,7 @@ import { Loading } from "../components/Loading"; import { LoadingError } from "../components/LoadingError"; import { MultiActionButton } from "../components/MultiActionButton"; import { ButtonBoxPrimary, ButtonPrimary } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { AddNewActionView } from "../wallet/AddNewActionView"; import * as wxApi from "../wxApi"; @@ -44,6 +44,7 @@ export function BalancePage({ goToWalletDeposit, goToWalletHistory, }: Props): VNode { + const { i18n } = useTranslationContext(); const [addingAction, setAddingAction] = useState(false); const state = useAsyncAsHook(wxApi.getBalance, [ NotificationType.WithdrawGroupFinished, @@ -92,6 +93,7 @@ export function BalanceView({ goToWalletHistory, goToAddAction, }: BalanceViewProps): VNode { + const { i18n } = useTranslationContext(); const currencyWithNonZeroAmount = balances .filter((b) => !Amounts.isZero(b.available)) .map((b) => b.available.split(":")[0]); diff --git a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx index 228c3cdfd..3144a9ce3 100644 --- a/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx +++ b/packages/taler-wallet-webextension/src/popup/DeveloperPage.tsx @@ -21,7 +21,6 @@ import { ExchangeListItem, NotificationType, Translate, - i18n, } from "@gnu-taler/taler-util"; import { PendingTaskInfo } from "@gnu-taler/taler-wallet-core"; import { format } from "date-fns"; @@ -30,6 +29,7 @@ import { useRef, useState } from "preact/hooks"; import { Diagnostics } from "../components/Diagnostics"; import { NotifyUpdateFadeOut } from "../components/styled"; import { Time } from "../components/Time"; +import { useTranslationContext } from "../context/translation"; import { useAsyncAsHook } from "../hooks/useAsyncAsHook"; import { useDiagnostics } from "../hooks/useDiagnostics"; import * as wxApi from "../wxApi"; @@ -110,6 +110,7 @@ export function View({ coins, onDownloadDatabase, }: Props): VNode { + const { i18n } = useTranslationContext(); const [downloadedDatabase, setDownloadedDatabase] = useState< { time: Date; content: string } | undefined >(undefined); @@ -153,7 +154,13 @@ export function View({

Debug tools:

-
@@ -262,6 +269,7 @@ function ShowAllCoins({ coins: SplitedCoinInfo; currencies: { [ex: string]: string }; }) { + const { i18n } = useTranslationContext(); const [collapsedSpent, setCollapsedSpent] = useState(true); const [collapsedUnspent, setCollapsedUnspent] = useState(false); const total = coins.usable.reduce((prev, cur) => prev + cur.denom_value, 0); @@ -372,12 +380,10 @@ export function reload(): void { function runIntegrationTest() {} -export async function confirmReset(): Promise { - if ( - confirm( - i18n.str`Do you want to IRREVOCABLY DESTROY everything inside your wallet and LOSE ALL YOUR COINS?`, - ) - ) { +export async function confirmReset( + confirmTheResetMessage: string, +): Promise { + if (confirm(confirmTheResetMessage)) { await wxApi.resetDb(); window.close(); } diff --git a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx index b8b21b24c..dfb99ac6a 100644 --- a/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx +++ b/packages/taler-wallet-webextension/src/popup/NoBalanceHelp.tsx @@ -1,12 +1,13 @@ -import { i18n } from "@gnu-taler/taler-util"; import { h, VNode } from "preact"; import { ButtonBoxWarning, WarningBox } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; export function NoBalanceHelp({ goToWalletManualWithdraw, }: { goToWalletManualWithdraw: () => void; }): VNode { + const { i18n } = useTranslationContext(); return (

diff --git a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx index 40b76a289..9ac83a578 100644 --- a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx +++ b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx @@ -19,9 +19,10 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { classifyTalerUri, TalerUriType, i18n } from "@gnu-taler/taler-util"; +import { classifyTalerUri, TalerUriType } from "@gnu-taler/taler-util"; import { Fragment, h } from "preact"; import { ButtonPrimary, ButtonSuccess } from "../components/styled"; +import { useTranslationContext } from "../context/translation"; import { actionForTalerUri } from "../utils/index"; export interface Props { @@ -49,6 +50,7 @@ async function navigateTo(url?: string) { export function TalerActionFound({ url, onDismiss }: Props) { const uriType = classifyTalerUri(url); + const { i18n } = useTranslationContext(); return (

-- cgit v1.2.3