From d57b6a4bcc595aee990b8e1c63e786e7796b737b Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 27 Nov 2016 22:13:24 +0100 Subject: modularize i18n --- src/pages/confirm-create-reserve.tsx | 41 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/pages/confirm-create-reserve.tsx') diff --git a/src/pages/confirm-create-reserve.tsx b/src/pages/confirm-create-reserve.tsx index 1ac56a8d0..da86729d3 100644 --- a/src/pages/confirm-create-reserve.tsx +++ b/src/pages/confirm-create-reserve.tsx @@ -30,6 +30,7 @@ import { } from "src/types"; import {getReserveCreationInfo} from "src/wxApi"; import {ImplicitStateComponent, StateHolder} from "src/components"; +import * as i18n from "src/i18n"; "use strict"; @@ -102,15 +103,15 @@ function renderReserveCreationDetails(rci: ReserveCreationInfo|null) { return (
-

{i18n`Withdrawal fees: ${withdrawFeeStr}`}

-

{i18n`Rounding loss: ${overheadStr}`}

+

{i18n.str`Withdrawal fees: ${withdrawFeeStr}`}

+

{i18n.str`Rounding loss: ${overheadStr}`}

- - - - - + + + + + {uniq.map(row)} @@ -143,7 +144,7 @@ function WithdrawFee(props: {reserveCreationInfo: ReserveCreationInfo|null}): JS if (props.reserveCreationInfo) { let {overhead, withdrawFee} = props.reserveCreationInfo; let totalCost = Amounts.add(overhead, withdrawFee).amount; - return

{i18n`Withdraw fees:`} {amountToPretty(totalCost)}

; + return

{i18n.str`Withdraw fees:`} {amountToPretty(totalCost)}

; } return

; } @@ -178,7 +179,7 @@ class ExchangeSelection extends ImplicitStateComponent { return ( ); } @@ -192,7 +193,7 @@ class ExchangeSelection extends ImplicitStateComponent { onInput={(e) => this.onUrlChanged((e.target as HTMLInputElement).value)}/>
{this.renderStatus()} -

{i18n`Detailed Fee Structure`}

+

{i18n.str`Detailed Fee Structure`}

{renderReserveCreationDetails(this.reserveCreationInfo())} ) } @@ -231,13 +232,13 @@ class ExchangeSelection extends ImplicitStateComponent { if (this.statusString()) { return (

- {i18n`A problem occured, see below.`} + {i18n.str`A problem occured, see below.`}

); } return (

- {i18n`Information about fees will be available when an exchange provider is selected.`} + {i18n.str`Information about fees will be available when an exchange provider is selected.`}

); } @@ -254,7 +255,7 @@ class ExchangeSelection extends ImplicitStateComponent {
{this.renderAdvanced()} @@ -276,7 +277,7 @@ class ExchangeSelection extends ImplicitStateComponent { async forceReserveUpdate() { this.reserveCreationInfo(null); if (!this.url()) { - this.statusString(i18n`Error: URL is empty`); + this.statusString(i18n.str`Error: URL is empty`); this.detailCollapsed(false); return; } @@ -284,7 +285,7 @@ class ExchangeSelection extends ImplicitStateComponent { this.statusString(null); let parsedUrl = URI(this.url()!); if (parsedUrl.is("relative")) { - this.statusString(i18n`Error: URL may not be relative`); + this.statusString(i18n.str`Error: URL may not be relative`); this.detailCollapsed(false); return; } @@ -344,7 +345,7 @@ class ExchangeSelection extends ImplicitStateComponent { } else { this.reset(); this.statusString( - i18n`Oops, something went wrong. The wallet responded with error status (${rawResp.error}).`); + i18n.str`Oops, something went wrong. The wallet responded with error status (${rawResp.error}).`); this.detailCollapsed(false); } }; @@ -370,7 +371,7 @@ class ExchangeSelection extends ImplicitStateComponent { if (this.statusString()) { return

{this.statusString()}

; } else if (!this.reserveCreationInfo()) { - return

{i18n`Checking URL, please wait ...`}

; + return

{i18n.str`Checking URL, please wait ...`}

; } return ""; } @@ -384,7 +385,7 @@ export async function main() { try { amount = AmountJson.checked(JSON.parse(query.amount)); } catch (e) { - throw Error(i18n`Can't parse amount: ${e.message}`); + throw Error(i18n.str`Can't parse amount: ${e.message}`); } const callback_url = query.callback_url; const bank_url = query.bank_url; @@ -392,7 +393,7 @@ export async function main() { try { wt_types = JSON.parse(query.wt_types); } catch (e) { - throw Error(i18n`Can't parse wire_types: ${e.message}`); + throw Error(i18n.str`Can't parse wire_types: ${e.message}`); } const suggestedExchangeUrl = await getSuggestedExchange(amount.currency); @@ -409,7 +410,7 @@ export async function main() { } catch (e) { // TODO: provide more context information, maybe factor it out into a // TODO:generic error reporting function or component. - document.body.innerText = i18n`Fatal error: "${e.message}".`; + document.body.innerText = i18n.str`Fatal error: "${e.message}".`; console.error(`got error "${e.message}"`, e); } } -- cgit v1.2.3
{i18n`# Coins`}{i18n`Value`}{i18n`Withdraw Fee`}{i18n`Refresh Fee`}{i18n`Deposit Fee`}{i18n.str`# Coins`}{i18n.str`Value`}{i18n.str`Withdraw Fee`}{i18n.str`Refresh Fee`}{i18n.str`Deposit Fee`}