WIP - change function calls to object attributes

tychovrahe/fw_translations/mpu
grdddj 8 months ago
parent 84efd9b585
commit 778e87a35a

@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
import storage.cache as storage_cache
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor import config, utils, wire, workflow
from trezor.enums import HomescreenFormat, MessageType
from trezor.messages import Success, UnlockPath
@ -222,9 +222,7 @@ async def handle_Ping(msg: Ping) -> Success:
from trezor.enums import ButtonRequestType as B
from trezor.ui.layouts import confirm_action
await confirm_action(
"ping", TR.tr("buttons__confirm"), "ping", br_code=B.ProtectCall
)
await confirm_action("ping", TR.buttons__confirm, "ping", br_code=B.ProtectCall)
return Success(message=msg.message)
@ -287,8 +285,8 @@ async def handle_UnlockPath(msg: UnlockPath) -> protobuf.MessageType:
await confirm_action(
"confirm_coinjoin_access",
title="Coinjoin",
description=TR.tr("coinjoin__access_account"),
verb=TR.tr("buttons__access"),
description=TR.coinjoin__access_account,
verb=TR.buttons__access,
)
wire_types = (MessageType.GetAddress, MessageType.GetPublicKey, MessageType.SignTx)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING, Sequence
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.strings import format_amount
from trezor.ui.layouts import confirm_properties
@ -30,10 +30,10 @@ async def require_confirm_transfer(msg: BinanceTransferMsg) -> None:
)
for txinput in msg.inputs:
make_input_output_pages(txinput, TR.tr("binance__confirm_input"))
make_input_output_pages(txinput, TR.binance__confirm_input)
for txoutput in msg.outputs:
make_input_output_pages(txoutput, TR.tr("binance__confirm_output"))
make_input_output_pages(txoutput, TR.binance__confirm_output)
await _confirm_transfer(items, chunkify=bool(msg.chunkify))
@ -52,11 +52,11 @@ async def _confirm_transfer(
async def require_confirm_cancel(msg: BinanceCancelMsg) -> None:
await confirm_properties(
"confirm_cancel",
TR.tr("binance__confirm_cancel"),
TR.binance__confirm_cancel,
(
(TR.tr("binance__sender_address"), str(msg.sender)),
(TR.tr("binance__pair"), str(msg.symbol)),
(TR.tr("binance__order_id"), str(msg.refid)),
(TR.binance__sender_address, str(msg.sender)),
(TR.binance__pair, str(msg.symbol)),
(TR.binance__order_id, str(msg.refid)),
),
hold=True,
br_code=ButtonRequestType.SignTx,
@ -67,21 +67,21 @@ async def require_confirm_order(msg: BinanceOrderMsg) -> None:
from trezor.enums import BinanceOrderSide
if msg.side == BinanceOrderSide.BUY:
side = TR.tr("binance__buy")
side = TR.binance__buy
elif msg.side == BinanceOrderSide.SELL:
side = TR.tr("binance__sell")
side = TR.binance__sell
else:
side = TR.tr("binance__unknown")
side = TR.binance__unknown
await confirm_properties(
"confirm_order",
TR.tr("binance__confirm_order"),
TR.binance__confirm_order,
(
(TR.tr("binance__sender_address"), str(msg.sender)),
(TR.tr("binance__pair"), str(msg.symbol)),
(TR.tr("binance__side"), side),
(TR.tr("binance__quantity"), format_amount(msg.quantity, DECIMALS)),
(TR.tr("binance__price"), format_amount(msg.price, DECIMALS)),
(TR.binance__sender_address, str(msg.sender)),
(TR.binance__pair, str(msg.symbol)),
(TR.binance__side, side),
(TR.binance__quantity, format_amount(msg.quantity, DECIMALS)),
(TR.binance__price, format_amount(msg.price, DECIMALS)),
),
hold=True,
br_code=ButtonRequestType.SignTx,

@ -19,7 +19,7 @@ _MAX_COORDINATOR_FEE_RATE = 5 * pow(10, FEE_RATE_DECIMALS) # 5 %
async def authorize_coinjoin(
msg: AuthorizeCoinJoin, keychain: Keychain, coin: CoinInfo
) -> Success:
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.messages import Success
from trezor.ui.layouts import confirm_coinjoin, confirm_metadata
@ -80,8 +80,8 @@ async def authorize_coinjoin(
if msg.max_fee_per_kvbyte > coin.maxfee_kb:
await confirm_metadata(
"fee_over_threshold",
TR.tr("bitcoin__title_high_mining_fee"),
TR.tr("bitcoin__high_mining_fee_template"),
TR.bitcoin__title_high_mining_fee,
TR.bitcoin__high_mining_fee_template,
max_fee_per_vbyte,
ButtonRequestType.FeeOverThreshold,
)

@ -31,7 +31,7 @@ def _get_xpubs(
@with_keychain
async def get_address(msg: GetAddress, keychain: Keychain, coin: CoinInfo) -> Address:
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import InputScriptType
from trezor.messages import Address
from trezor.ui.layouts import show_address, show_warning
@ -103,8 +103,8 @@ async def get_address(msg: GetAddress, keychain: Keychain, coin: CoinInfo) -> Ad
await show_warning(
"warning_multisig",
TR.tr("send__receiving_to_multisig"),
TR.tr("words__continue_anyway"),
TR.send__receiving_to_multisig,
TR.words__continue_anyway,
)
await show_address(
@ -119,7 +119,7 @@ async def get_address(msg: GetAddress, keychain: Keychain, coin: CoinInfo) -> Ad
else:
account_name = address_n_to_name(coin, address_n, script_type)
if account_name is None:
account = TR.tr("bitcoin__unknown_path")
account = TR.bitcoin__unknown_path
elif account_name == "":
account = coin.coin_shortcut
else:

@ -18,7 +18,7 @@ async def get_ownership_proof(
coin: CoinInfo,
authorization: CoinJoinAuthorization | None = None,
) -> OwnershipProof:
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import InputScriptType
from trezor.messages import OwnershipProof
from trezor.ui.layouts import confirm_action, confirm_blob
@ -72,15 +72,15 @@ async def get_ownership_proof(
if msg.user_confirmation and not authorization:
await confirm_action(
"confirm_ownership_proof",
TR.tr("bitcoin__title_proof_of_ownership"),
description=TR.tr("bitcoin__create_proof_of_ownership"),
TR.bitcoin__title_proof_of_ownership,
description=TR.bitcoin__create_proof_of_ownership,
)
if msg.commitment_data:
await confirm_blob(
"confirm_ownership_proof",
TR.tr("bitcoin__title_proof_of_ownership"),
TR.bitcoin__title_proof_of_ownership,
msg.commitment_data,
TR.tr("bitcoin__commitment_data"),
TR.bitcoin__commitment_data,
)
ownership_proof, signature = generate_proof(

@ -8,7 +8,7 @@ if TYPE_CHECKING:
async def get_public_key(
msg: GetPublicKey, auth_msg: MessageType | None = None
) -> PublicKey:
import trezortranslate as TR
from trezortranslate import TR
from trezor import wire
from trezor.enums import InputScriptType
from trezor.messages import HDNodeType, PublicKey, UnlockPath
@ -102,7 +102,7 @@ async def get_public_key(
"XPUB",
account=account,
path=path,
mismatch_title=TR.tr("addr_mismatch__xpub_mismatch"),
mismatch_title=TR.addr_mismatch__xpub_mismatch,
br_type="show_xpub",
)

@ -257,18 +257,18 @@ class BasicApprover(Approver):
def _replacement_title(
self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]
) -> str:
import trezortranslate as TR
from trezortranslate import TR
if self.is_payjoin():
return TR.tr("bitcoin__title_payjoin")
return TR.bitcoin__title_payjoin
elif tx_info.rbf_disabled() and any(
not orig.rbf_disabled() for orig in orig_txs
):
return TR.tr("bitcoin__title_finalize_transaction")
return TR.bitcoin__title_finalize_transaction
elif len(orig_txs) > 1:
return TR.tr("bitcoin__title_meld_transaction")
return TR.bitcoin__title_meld_transaction
else:
return TR.tr("bitcoin__title_update_transaction")
return TR.bitcoin__title_update_transaction
async def approve_tx(self, tx_info: TxInfo, orig_txs: list[OriginalTxInfo]) -> None:
from trezor.wire import NotEnoughFunds

@ -1,7 +1,7 @@
from micropython import const
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.strings import format_amount
from trezor.ui import layouts
@ -51,7 +51,7 @@ def format_coin_amount(amount: int, coin: CoinInfo, amount_unit: AmountUnit) ->
def account_label(coin: CoinInfo, address_n: Bip32Path | None) -> str:
return (
TR.tr("bitcoin__multiple_accounts")
TR.bitcoin__multiple_accounts
if address_n is None
else address_n_to_name(coin, list(address_n) + [0] * BIP32_WALLET_DEPTH)
or f"Path {address_n_to_str(address_n)}"
@ -78,7 +78,7 @@ async def confirm_output(
"omni_transaction",
"OMNI transaction",
omni.parse(data),
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
br_code=ButtonRequestType.ConfirmOutput,
)
else:
@ -93,7 +93,7 @@ async def confirm_output(
assert output.address is not None
address_short = addresses.address_short(coin, output.address)
if output.payment_req_index is not None:
title = TR.tr("bitcoin__title_confirm_details")
title = TR.bitcoin__title_confirm_details
else:
title = None
@ -111,7 +111,7 @@ async def confirm_output(
script_type,
show_account_str=show_account_str,
)
or f"{TR.tr('send__address_path')} {address_n_to_str(output.address_n)}"
or f"{TR.send__address_path} {address_n_to_str(output.address_n)}"
)
layout = layouts.confirm_output(
@ -134,21 +134,21 @@ async def confirm_decred_sstx_submission(
amount = format_coin_amount(output.amount, coin, amount_unit)
await layouts.confirm_value(
TR.tr("bitcoin__title_purchase_ticket"),
TR.bitcoin__title_purchase_ticket,
amount,
TR.tr("bitcoin__ticket_amount"),
TR.bitcoin__ticket_amount,
"confirm_decred_sstx_submission",
ButtonRequestType.ConfirmOutput,
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)
await layouts.confirm_value(
TR.tr("bitcoin__title_purchase_ticket"),
TR.bitcoin__title_purchase_ticket,
address_short,
TR.tr("bitcoin__voting_rights"),
TR.bitcoin__voting_rights,
"confirm_decred_sstx_submission",
ButtonRequestType.ConfirmOutput,
verb=TR.tr("buttons__purchase"),
verb=TR.buttons__purchase,
)
@ -167,7 +167,7 @@ async def confirm_payment_request(
pass
elif m.coin_purchase_memo is not None:
memo_texts.append(
f"{TR.tr('words__buying')} {m.coin_purchase_memo.amount}."
f"{TR.words__buying} {m.coin_purchase_memo.amount}."
)
else:
raise wire.DataError("Unrecognized memo type in payment request memo.")
@ -259,7 +259,7 @@ async def confirm_feeoverthreshold(
fee_amount = format_coin_amount(fee, coin, amount_unit)
await layouts.show_warning(
"fee_over_threshold",
TR.tr("bitcoin__unusually_high_fee"),
TR.bitcoin__unusually_high_fee,
fee_amount,
br_code=ButtonRequestType.FeeOverThreshold,
)
@ -268,8 +268,8 @@ async def confirm_feeoverthreshold(
async def confirm_change_count_over_threshold(change_count: int) -> None:
await layouts.show_warning(
"change_count_over_threshold",
TR.tr("bitcoin__lot_of_change_outputs"),
f"{str(change_count)} {TR.tr('words__outputs')}",
TR.bitcoin__lot_of_change_outputs,
f"{str(change_count)} {TR.words__outputs}",
br_code=ButtonRequestType.SignTx,
)
@ -277,9 +277,9 @@ async def confirm_change_count_over_threshold(change_count: int) -> None:
async def confirm_unverified_external_input() -> None:
await layouts.show_warning(
"unverified_external_input",
TR.tr("bitcoin__unverified_external_inputs"),
TR.tr("words__continue_anyway"),
button=TR.tr("buttons__continue"),
TR.bitcoin__unverified_external_inputs,
TR.words__continue_anyway,
button=TR.buttons__continue,
br_code=ButtonRequestType.SignTx,
)
@ -287,9 +287,9 @@ async def confirm_unverified_external_input() -> None:
async def confirm_multiple_accounts() -> None:
await layouts.show_warning(
"sending_from_multiple_accounts",
TR.tr("send__from_multiple_accounts"),
TR.tr("words__continue_anyway"),
button=TR.tr("buttons__continue"),
TR.send__from_multiple_accounts,
TR.words__continue_anyway,
button=TR.buttons__continue,
br_code=ButtonRequestType.SignTx,
)
@ -300,23 +300,23 @@ async def confirm_nondefault_locktime(lock_time: int, lock_time_disabled: bool)
if lock_time_disabled:
await layouts.show_warning(
"nondefault_locktime",
TR.tr("bitcoin__locktime_no_effect"),
TR.tr("words__continue_anyway"),
button=TR.tr("buttons__continue"),
TR.bitcoin__locktime_no_effect,
TR.words__continue_anyway,
button=TR.buttons__continue,
br_code=ButtonRequestType.SignTx,
)
else:
if lock_time < _LOCKTIME_TIMESTAMP_MIN_VALUE:
text = TR.tr("bitcoin__locktime_set_to_blockheight")
text = TR.bitcoin__locktime_set_to_blockheight
value = str(lock_time)
else:
text = TR.tr("bitcoin__locktime_set_to")
text = TR.bitcoin__locktime_set_to
value = format_timestamp(lock_time)
await layouts.confirm_value(
TR.tr("bitcoin__confirm_locktime"),
TR.bitcoin__confirm_locktime,
value,
text,
"nondefault_locktime",
br_code=ButtonRequestType.SignTx,
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)

@ -17,7 +17,7 @@ def is_valid(data: bytes) -> bool:
def parse(data: bytes) -> str:
from ustruct import unpack
import trezortranslate as TR
from trezortranslate import TR
from trezor.strings import format_amount
if not is_valid(data):
@ -26,7 +26,7 @@ def parse(data: bytes) -> str:
if tx_version == 0 and tx_type == 0 and len(data) == 20: # OMNI simple send
currency, amount = unpack(">IQ", data[8:20])
suffix, decimals = currencies.get(currency, ("UNKN", 0))
return f"{TR.tr('bitcoin__simple_send_of')} {format_amount(amount, decimals)} {suffix}"
return f"{TR.bitcoin__simple_send_of} {format_amount(amount, decimals)} {suffix}"
else:
# unknown OMNI transaction
return TR.tr("bitcoin__unknown_transaction")
return TR.bitcoin__unknown_transaction

@ -112,16 +112,16 @@ class Progress:
self.report()
def report_init(self) -> None:
import trezortranslate as TR
from trezortranslate import TR
from trezor import workflow
from trezor.ui.layouts.progress import bitcoin_progress, coinjoin_progress
progress_layout = coinjoin_progress if self.is_coinjoin else bitcoin_progress
workflow.close_others()
text = (
TR.tr("progress__signing_transaction")
TR.progress__signing_transaction
if self.signing
else TR.tr("progress__loading_transaction")
else TR.progress__loading_transaction
)
self.progress_layout = progress_layout(text)

@ -51,7 +51,7 @@ def _address_to_script_type(address: str, coin: CoinInfo) -> InputScriptType:
async def verify_message(msg: VerifyMessage) -> Success:
import trezortranslate as TR
from trezortranslate import TR
from trezor import utils
from trezor.crypto.curve import secp256k1
from trezor.enums import InputScriptType
@ -118,5 +118,5 @@ async def verify_message(msg: VerifyMessage) -> Success:
verify=True,
)
await show_success("verify_message", TR.tr("bitcoin__valid_signature"))
await show_success("verify_message", TR.bitcoin__valid_signature)
return Success(message="Message verified")

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
from ubinascii import hexlify
import trezortranslate as TR
from trezortranslate import TR
from . import seed
@ -40,7 +40,7 @@ async def get_public_key(
from apps.common.paths import address_n_to_str
path = address_n_to_str(address_n)
await show_pubkey(key.xpub, TR.tr("address__public_key"), path=path)
await show_pubkey(key.xpub, TR.address__public_key, path=path)
return key

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import CardanoAddressType
from .paths import SCHEMA_PAYMENT
@ -164,13 +164,13 @@ class Credential:
def get_title(self) -> str:
if self.path:
return TR.tr("cardano__path")
return TR.cardano__path
elif self.key_hash:
return TR.tr("cardano__key_hash")
return TR.cardano__key_hash
elif self.script_hash:
return TR.tr("cardano__script")
return TR.cardano__script
elif self.pointer:
return TR.tr("cardano__pointer")
return TR.cardano__pointer
else:
return ""
@ -193,9 +193,9 @@ class Credential:
return [(None, bech32.encode(bech32.HRP_SCRIPT_HASH, self.script_hash))]
elif pointer:
return [
(f"{TR.tr('cardano__block')}: {pointer.block_index}", None),
(f"{TR.tr('cardano__transaction')}: {pointer.tx_index}", None),
(f"{TR.tr('cardano__certificate')}: {pointer.certificate_index}", None),
(f"{TR.cardano__block}: {pointer.block_index}", None),
(f"{TR.cardano__transaction}: {pointer.tx_index}", None),
(f"{TR.cardano__certificate}: {pointer.certificate_index}", None),
]
else:
return []

@ -32,8 +32,8 @@ WITNESS_PATH_NAME = "Witness path"
# TODO: these appear also in DataErrors being thrown,
# so device tests would fail with translations
# CHANGE_OUTPUT_PATH_NAME = TR.tr('cardano__change_output_path')
# CHANGE_OUTPUT_STAKING_PATH_NAME = TR.tr('cardano__change_output_staking_path')
# CERTIFICATE_PATH_NAME = TR.tr('cardano__certificate_path')
# POOL_OWNER_STAKING_PATH_NAME = TR.tr('cardano__pool_owner_path')
# WITNESS_PATH_NAME = TR.tr('cardano__witness_path')
# CHANGE_OUTPUT_PATH_NAME = TR.cardano__change_output_path
# CHANGE_OUTPUT_STAKING_PATH_NAME = TR.cardano__change_output_staking_path
# CERTIFICATE_PATH_NAME = TR.cardano__certificate_path
# POOL_OWNER_STAKING_PATH_NAME = TR.cardano__pool_owner_path
# WITNESS_PATH_NAME = TR.cardano__witness_path

@ -1,6 +1,6 @@
from micropython import const
import trezortranslate as TR
from trezortranslate import TR
# https://book.world.dev.cardano.org/environments.html
MAINNET = const(764824073)
@ -21,4 +21,4 @@ def is_mainnet(protocol_magic: int) -> bool:
def to_ui_string(value: int) -> str:
return NAMES.get(value, TR.tr("cardano__unknown"))
return NAMES.get(value, TR.cardano__unknown)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor import ui
from trezor.enums import (
ButtonRequestType,
@ -35,42 +35,38 @@ if TYPE_CHECKING:
ADDRESS_TYPE_NAMES = {
CardanoAddressType.BYRON: TR.tr("cardano__addr_legacy"),
CardanoAddressType.BASE: TR.tr("cardano__addr_base"),
CardanoAddressType.BASE_SCRIPT_KEY: TR.tr("cardano__addr_base"),
CardanoAddressType.BASE_KEY_SCRIPT: TR.tr("cardano__addr_base"),
CardanoAddressType.BASE_SCRIPT_SCRIPT: TR.tr("cardano__addr_base"),
CardanoAddressType.POINTER: TR.tr("cardano__addr_pointer"),
CardanoAddressType.POINTER_SCRIPT: TR.tr("cardano__addr_pointer"),
CardanoAddressType.ENTERPRISE: TR.tr("cardano__addr_enterprise"),
CardanoAddressType.ENTERPRISE_SCRIPT: TR.tr("cardano__addr_enterprise"),
CardanoAddressType.REWARD: TR.tr("cardano__addr_reward"),
CardanoAddressType.REWARD_SCRIPT: TR.tr("cardano__addr_reward"),
CardanoAddressType.BYRON: TR.cardano__addr_legacy,
CardanoAddressType.BASE: TR.cardano__addr_base,
CardanoAddressType.BASE_SCRIPT_KEY: TR.cardano__addr_base,
CardanoAddressType.BASE_KEY_SCRIPT: TR.cardano__addr_base,
CardanoAddressType.BASE_SCRIPT_SCRIPT: TR.cardano__addr_base,
CardanoAddressType.POINTER: TR.cardano__addr_pointer,
CardanoAddressType.POINTER_SCRIPT: TR.cardano__addr_pointer,
CardanoAddressType.ENTERPRISE: TR.cardano__addr_enterprise,
CardanoAddressType.ENTERPRISE_SCRIPT: TR.cardano__addr_enterprise,
CardanoAddressType.REWARD: TR.cardano__addr_reward,
CardanoAddressType.REWARD_SCRIPT: TR.cardano__addr_reward,
}
SCRIPT_TYPE_NAMES = {
CardanoNativeScriptType.PUB_KEY: TR.tr("cardano__script_key"),
CardanoNativeScriptType.ALL: TR.tr("cardano__script_all"),
CardanoNativeScriptType.ANY: TR.tr("cardano__script_any"),
CardanoNativeScriptType.N_OF_K: TR.tr("cardano__script_n_of_k"),
CardanoNativeScriptType.INVALID_BEFORE: TR.tr("cardano__script_invalid_before"),
CardanoNativeScriptType.INVALID_HEREAFTER: TR.tr(
"cardano__script_invalid_hereafter"
),
CardanoNativeScriptType.PUB_KEY: TR.cardano__script_key,
CardanoNativeScriptType.ALL: TR.cardano__script_all,
CardanoNativeScriptType.ANY: TR.cardano__script_any,
CardanoNativeScriptType.N_OF_K: TR.cardano__script_n_of_k,
CardanoNativeScriptType.INVALID_BEFORE: TR.cardano__script_invalid_before,
CardanoNativeScriptType.INVALID_HEREAFTER: TR.cardano__script_invalid_hereafter,
}
CERTIFICATE_TYPE_NAMES = {
CardanoCertificateType.STAKE_REGISTRATION: TR.tr("cardano__stake_registration"),
CardanoCertificateType.STAKE_DEREGISTRATION: TR.tr("cardano__stake_deregistration"),
CardanoCertificateType.STAKE_DELEGATION: TR.tr("cardano__stake_delegation"),
CardanoCertificateType.STAKE_POOL_REGISTRATION: TR.tr(
"cardano__stake_pool_registration"
),
CardanoCertificateType.STAKE_REGISTRATION: TR.cardano__stake_registration,
CardanoCertificateType.STAKE_DEREGISTRATION: TR.cardano__stake_deregistration,
CardanoCertificateType.STAKE_DELEGATION: TR.cardano__stake_delegation,
CardanoCertificateType.STAKE_POOL_REGISTRATION: TR.cardano__stake_pool_registration,
}
BRT_Other = ButtonRequestType.Other # global_import_cache
CVOTE_REWARD_ELIGIBILITY_WARNING = TR.tr("cardano__reward_eligibility_warning")
CVOTE_REWARD_ELIGIBILITY_WARNING = TR.cardano__reward_eligibility_warning
def format_coin_amount(amount: int, network_id: int) -> str:
@ -121,7 +117,7 @@ async def show_native_script(
assert script.required_signatures_count is not None # validate_script
append(
(
TR.tr("cardano__x_of_y_signatures_template").format(
TR.cardano__x_of_y_signatures_template.format(
script.required_signatures_count, len(scripts)
),
None,
@ -140,11 +136,11 @@ async def show_native_script(
CNST.N_OF_K,
):
assert scripts # validate_script
append((TR.tr("cardano__nested_scripts_template").format(len(scripts)), None))
append((TR.cardano__nested_scripts_template.format(len(scripts)), None))
await confirm_properties(
"verify_script",
TR.tr("cardano__verify_script"),
TR.cardano__verify_script,
props,
br_code=BRT_Other,
)
@ -167,10 +163,10 @@ async def show_script_hash(
if display_format == CardanoNativeScriptHashDisplayFormat.BECH32:
await confirm_properties(
"verify_script",
TR.tr("cardano__verify_script"),
TR.cardano__verify_script,
(
(
TR.tr("cardano__script_hash"),
TR.cardano__script_hash,
bech32.encode(bech32.HRP_SCRIPT_HASH, script_hash),
),
),
@ -179,25 +175,25 @@ async def show_script_hash(
elif display_format == CardanoNativeScriptHashDisplayFormat.POLICY_ID:
await layouts.confirm_blob(
"verify_script",
TR.tr("cardano__verify_script"),
TR.cardano__verify_script,
script_hash,
TR.tr("cardano__policy_id"),
TR.cardano__policy_id,
br_code=BRT_Other,
)
async def show_tx_init(title: str) -> bool:
should_show_details = await layouts.should_show_more(
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
ui.DEMIBOLD,
title,
),
(ui.NORMAL, TR.tr("cardano__choose_level_of_details")),
(ui.NORMAL, TR.cardano__choose_level_of_details),
),
TR.tr("buttons__show_all"),
confirm=TR.tr("cardano__show_simple"),
TR.buttons__show_all,
confirm=TR.cardano__show_simple,
)
return should_show_details
@ -206,10 +202,10 @@ async def show_tx_init(title: str) -> bool:
async def confirm_input(input: messages.CardanoTxInput) -> None:
await confirm_properties(
"confirm_input",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(TR.tr("cardano__input_id"), input.prev_hash),
(TR.tr("cardano__input_index"), str(input.prev_index)),
(TR.cardano__input_id, input.prev_hash),
(TR.cardano__input_index, str(input.prev_index)),
),
br_code=BRT_Other,
)
@ -223,11 +219,11 @@ async def confirm_sending(
chunkify: bool,
) -> None:
if output_type == "address":
title = TR.tr("cardano__sending")
title = TR.cardano__sending
elif output_type == "change":
title = TR.tr("cardano__change_output")
title = TR.cardano__change_output
elif output_type == "collateral-return":
title = TR.tr("cardano__collateral_return")
title = TR.cardano__collateral_return
else:
raise RuntimeError # should be unreachable
@ -245,16 +241,16 @@ async def confirm_sending_token(policy_id: bytes, token: messages.CardanoToken)
await confirm_properties(
"confirm_token",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
TR.tr("cardano__asset_fingerprint"),
TR.cardano__asset_fingerprint,
format_asset_fingerprint(
policy_id=policy_id,
asset_name_bytes=token.asset_name_bytes,
),
),
(TR.tr("cardano__amount_sent"), format_amount(token.amount, 0)),
(TR.cardano__amount_sent, format_amount(token.amount, 0)),
),
br_code=BRT_Other,
)
@ -263,10 +259,10 @@ async def confirm_sending_token(policy_id: bytes, token: messages.CardanoToken)
async def confirm_datum_hash(datum_hash: bytes) -> None:
await confirm_properties(
"confirm_datum_hash",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
TR.tr("cardano__datum_hash"),
TR.cardano__datum_hash,
bech32.encode(bech32.HRP_OUTPUT_DATUM_HASH, datum_hash),
),
),
@ -277,7 +273,7 @@ async def confirm_datum_hash(datum_hash: bytes) -> None:
async def confirm_inline_datum(first_chunk: bytes, inline_datum_size: int) -> None:
await _confirm_data_chunk(
"confirm_inline_datum",
TR.tr("cardano__inline_datum"),
TR.cardano__inline_datum,
first_chunk,
inline_datum_size,
)
@ -288,7 +284,7 @@ async def confirm_reference_script(
) -> None:
await _confirm_data_chunk(
"confirm_reference_script",
TR.tr("cardano__reference_script"),
TR.cardano__reference_script,
first_chunk,
reference_script_size,
)
@ -310,7 +306,7 @@ async def _confirm_data_chunk(
props.append(("...", None))
await confirm_properties(
br_type,
title=TR.tr("cardano__confirm_transaction"),
title=TR.cardano__confirm_transaction,
props=props,
br_code=BRT_Other,
)
@ -320,7 +316,7 @@ async def show_credentials(
payment_credential: Credential,
stake_credential: Credential,
) -> None:
intro_text = TR.tr("cardano__intro_text_address")
intro_text = TR.cardano__intro_text_address
await _show_credential(payment_credential, intro_text, purpose="address")
await _show_credential(stake_credential, intro_text, purpose="address")
@ -329,7 +325,7 @@ async def show_change_output_credentials(
payment_credential: Credential,
stake_credential: Credential,
) -> None:
intro_text = TR.tr("cardano__intro_text_change")
intro_text = TR.cardano__intro_text_change
await _show_credential(payment_credential, intro_text, purpose="output")
await _show_credential(stake_credential, intro_text, purpose="output")
@ -339,7 +335,7 @@ async def show_device_owned_output_credentials(
stake_credential: Credential,
show_both_credentials: bool,
) -> None:
intro_text = TR.tr("cardano__intro_text_owned_by_device")
intro_text = TR.cardano__intro_text_owned_by_device
await _show_credential(payment_credential, intro_text, purpose="output")
if show_both_credentials:
await _show_credential(stake_credential, intro_text, purpose="output")
@ -351,7 +347,7 @@ async def show_cvote_registration_payment_credentials(
show_both_credentials: bool,
show_payment_warning: bool,
) -> None:
intro_text = TR.tr("cardano__intro_text_registration_payment")
intro_text = TR.cardano__intro_text_registration_payment
await _show_credential(
payment_credential, intro_text, purpose="cvote_reg_payment_address"
@ -374,8 +370,8 @@ async def _show_credential(
) -> None:
title = {
"address": f"{ADDRESS_TYPE_NAMES[credential.address_type]} address",
"output": TR.tr("cardano__confirm_transaction"),
"cvote_reg_payment_address": TR.tr("cardano__confirm_transaction"),
"output": TR.cardano__confirm_transaction,
"cvote_reg_payment_address": TR.cardano__confirm_transaction,
}[purpose]
props: list[PropertyType] = []
@ -396,16 +392,16 @@ async def _show_credential(
props.extend(credential.format())
if credential.is_unusual_path:
append((None, TR.tr("cardano__unusual_path")))
append((None, TR.cardano__unusual_path))
if credential.is_mismatch:
append((None, TR.tr("cardano__credential_mismatch")))
append((None, TR.cardano__credential_mismatch))
if credential.is_reward and purpose != "cvote_reg_payment_address":
# for cvote registrations, this is handled by extra_text at the end
append((TR.tr("cardano__reward_address"), None))
append((TR.cardano__reward_address, None))
if credential.is_no_staking:
append(
(
f"{ADDRESS_TYPE_NAMES[credential.address_type]} {TR.tr('cardano__address_no_staking')}",
f"{ADDRESS_TYPE_NAMES[credential.address_type]} {TR.cardano__address_no_staking}",
None,
)
)
@ -428,13 +424,13 @@ async def warn_path(path: list[int], title: str) -> None:
async def warn_tx_output_contains_tokens(is_collateral_return: bool = False) -> None:
content = (
TR.tr("cardano__collateral_output_contains_tokens")
TR.cardano__collateral_output_contains_tokens
if is_collateral_return
else TR.tr("cardano__transaction_output_contains_tokens")
else TR.cardano__transaction_output_contains_tokens
)
await confirm_metadata(
"confirm_tokens",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
content,
br_code=BRT_Other,
)
@ -443,8 +439,8 @@ async def warn_tx_output_contains_tokens(is_collateral_return: bool = False) ->
async def warn_tx_contains_mint() -> None:
await confirm_metadata(
"confirm_tokens",
TR.tr("cardano__confirm_transaction"),
TR.tr("cardano__transaction_contains_minting_or_burning"),
TR.cardano__confirm_transaction,
TR.cardano__transaction_contains_minting_or_burning,
br_code=BRT_Other,
)
@ -452,8 +448,8 @@ async def warn_tx_contains_mint() -> None:
async def warn_tx_output_no_datum() -> None:
await confirm_metadata(
"confirm_no_datum_hash",
TR.tr("cardano__confirm_transaction"),
TR.tr("cardano__transaction_contains_script_address_no_datum"),
TR.cardano__confirm_transaction,
TR.cardano__transaction_contains_script_address_no_datum,
br_code=BRT_Other,
)
@ -461,8 +457,8 @@ async def warn_tx_output_no_datum() -> None:
async def warn_no_script_data_hash() -> None:
await confirm_metadata(
"confirm_no_script_data_hash",
TR.tr("cardano__confirm_transaction"),
TR.tr("cardano__transaction_no_script_data_hash"),
TR.cardano__confirm_transaction,
TR.cardano__transaction_no_script_data_hash,
br_code=BRT_Other,
)
@ -470,8 +466,8 @@ async def warn_no_script_data_hash() -> None:
async def warn_no_collateral_inputs() -> None:
await confirm_metadata(
"confirm_no_collateral_inputs",
TR.tr("cardano__confirm_transaction"),
TR.tr("cardano__transaction_no_collateral_input"),
TR.cardano__confirm_transaction,
TR.cardano__transaction_no_collateral_input,
br_code=BRT_Other,
)
@ -479,8 +475,8 @@ async def warn_no_collateral_inputs() -> None:
async def warn_unknown_total_collateral() -> None:
await layouts.show_warning(
"confirm_unknown_total_collateral",
TR.tr("cardano__unknown_collateral_amount"),
TR.tr("cardano__check_all_items"),
TR.cardano__unknown_collateral_amount,
TR.cardano__check_all_items,
br_code=BRT_Other,
)
@ -491,17 +487,17 @@ async def confirm_witness_request(
from . import seed
if seed.is_multisig_path(witness_path):
path_title = TR.tr("cardano__multisig_path")
path_title = TR.cardano__multisig_path
elif seed.is_minting_path(witness_path):
path_title = TR.tr("cardano__token_minting_path")
path_title = TR.cardano__token_minting_path
else:
path_title = TR.tr("cardano__path")
path_title = TR.cardano__path
await layouts.confirm_text(
"confirm_total",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
address_n_to_str(witness_path),
TR.tr("cardano__sign_tx_path_template").format(path_title),
TR.cardano__sign_tx_path_template.format(path_title),
BRT_Other,
)
@ -517,14 +513,14 @@ async def confirm_tx(
tx_hash: bytes | None,
) -> None:
props: list[PropertyType] = [
(TR.tr("cardano__transaction_fee"), format_coin_amount(fee, network_id)),
(TR.cardano__transaction_fee, format_coin_amount(fee, network_id)),
]
append = props.append # local_cache_attribute
if total_collateral is not None:
append(
(
TR.tr("cardano__total_collateral"),
TR.cardano__total_collateral,
format_coin_amount(total_collateral, network_id),
)
)
@ -532,25 +528,25 @@ async def confirm_tx(
if is_network_id_verifiable:
append(
(
f"{TR.tr('cardano__network')} {protocol_magics.to_ui_string(protocol_magic)}",
f"{TR.cardano__network} {protocol_magics.to_ui_string(protocol_magic)}",
None,
)
)
append(
(
f"{TR.tr('cardano__valid_since')} {format_optional_int(validity_interval_start)}",
f"{TR.cardano__valid_since} {format_optional_int(validity_interval_start)}",
None,
)
)
append((f"{TR.tr('cardano__ttl')} {format_optional_int(ttl)}", None))
append((f"{TR.cardano__ttl} {format_optional_int(ttl)}", None))
if tx_hash:
append((TR.tr("cardano__transaction_id"), tx_hash))
append((TR.cardano__transaction_id, tx_hash))
await confirm_properties(
"confirm_total",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
props,
hold=True,
br_code=BRT_Other,
@ -563,7 +559,7 @@ async def confirm_certificate(certificate: messages.CardanoTxCertificate) -> Non
assert certificate.type != CardanoCertificateType.STAKE_POOL_REGISTRATION
props: list[PropertyType] = [
(TR.tr("cardano__confirm"), CERTIFICATE_TYPE_NAMES[certificate.type]),
(TR.cardano__confirm, CERTIFICATE_TYPE_NAMES[certificate.type]),
_format_stake_credential(
certificate.path, certificate.script_hash, certificate.key_hash
),
@ -571,13 +567,11 @@ async def confirm_certificate(certificate: messages.CardanoTxCertificate) -> Non
if certificate.type == CardanoCertificateType.STAKE_DELEGATION:
assert certificate.pool is not None # validate_certificate
props.append(
(TR.tr("cardano__to_pool"), format_stake_pool_id(certificate.pool))
)
props.append((TR.cardano__to_pool, format_stake_pool_id(certificate.pool)))
await confirm_properties(
"confirm_certificate",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
props,
br_code=BRT_Other,
)
@ -593,17 +587,17 @@ async def confirm_stake_pool_parameters(
percentage_formatted = str(float(margin_percentage)).rstrip("0").rstrip(".")
await confirm_properties(
"confirm_pool_registration",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
TR.tr("cardano__stake_pool_registration_pool_id"),
TR.cardano__stake_pool_registration_pool_id,
format_stake_pool_id(pool_parameters.pool_id),
),
(TR.tr("cardano__pool_reward_account"), pool_parameters.reward_account),
(TR.cardano__pool_reward_account, pool_parameters.reward_account),
(
f"{TR.tr('cardano__pledge')}: {format_coin_amount(pool_parameters.pledge, network_id)}\n"
+ f"{TR.tr('cardano__cost')}: {format_coin_amount(pool_parameters.cost, network_id)}\n"
+ f"{TR.tr('cardano__margin')}: {percentage_formatted}%",
f"{TR.cardano__pledge}: {format_coin_amount(pool_parameters.pledge, network_id)}\n"
+ f"{TR.cardano__cost}: {format_coin_amount(pool_parameters.cost, network_id)}\n"
+ f"{TR.cardano__margin}: {percentage_formatted}%",
None,
),
),
@ -621,9 +615,7 @@ async def confirm_stake_pool_owner(
props: list[tuple[str, str | None]] = []
if owner.staking_key_path:
props.append(
(TR.tr("cardano__pool_owner"), address_n_to_str(owner.staking_key_path))
)
props.append((TR.cardano__pool_owner, address_n_to_str(owner.staking_key_path)))
props.append(
(
addresses.derive_human_readable(
@ -642,7 +634,7 @@ async def confirm_stake_pool_owner(
assert owner.staking_key_hash is not None # validate_pool_owners
props.append(
(
TR.tr("cardano__pool_owner"),
TR.cardano__pool_owner,
addresses.derive_human_readable(
keychain,
messages.CardanoAddressParametersType(
@ -657,7 +649,7 @@ async def confirm_stake_pool_owner(
await confirm_properties(
"confirm_pool_owners",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
props,
br_code=BRT_Other,
)
@ -669,18 +661,18 @@ async def confirm_stake_pool_metadata(
if metadata is None:
await confirm_properties(
"confirm_pool_metadata",
TR.tr("cardano__confirm_transaction"),
((TR.tr("cardano__anonymous_pool"), None),),
TR.cardano__confirm_transaction,
((TR.cardano__anonymous_pool, None),),
br_code=BRT_Other,
)
return
await confirm_properties(
"confirm_pool_metadata",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(TR.tr("cardano__pool_metadata_url"), metadata.url),
(TR.tr("cardano__pool_metadata_hash"), metadata.hash),
(TR.cardano__pool_metadata_url, metadata.url),
(TR.cardano__pool_metadata_hash, metadata.hash),
),
br_code=BRT_Other,
)
@ -693,15 +685,15 @@ async def confirm_stake_pool_registration_final(
) -> None:
await confirm_properties(
"confirm_pool_final",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(TR.tr("cardano__confirm_signing_stake_pool"), None),
(TR.tr("cardano__network"), protocol_magics.to_ui_string(protocol_magic)),
(TR.cardano__confirm_signing_stake_pool, None),
(TR.cardano__network, protocol_magics.to_ui_string(protocol_magic)),
(
TR.tr("cardano__valid_since"),
TR.cardano__valid_since,
format_optional_int(validity_interval_start),
),
(TR.tr("cardano__ttl"), format_optional_int(ttl)),
(TR.cardano__ttl, format_optional_int(ttl)),
),
hold=True,
br_code=BRT_Other,
@ -714,14 +706,12 @@ async def confirm_withdrawal(
network_id: int,
) -> None:
address_type_name = (
TR.tr("cardano__script_reward")
if withdrawal.script_hash
else TR.tr("cardano__reward")
TR.cardano__script_reward if withdrawal.script_hash else TR.cardano__reward
)
address = addresses.encode_human_readable(address_bytes)
props: list[PropertyType] = [
(
TR.tr("cardano__withdrawal_for_address_template").format(address_type_name),
TR.cardano__withdrawal_for_address_template.format(address_type_name),
address,
),
]
@ -734,12 +724,12 @@ async def confirm_withdrawal(
)
props.append(
(TR.tr("cardano__amount"), format_coin_amount(withdrawal.amount, network_id))
(TR.cardano__amount, format_coin_amount(withdrawal.amount, network_id))
)
await confirm_properties(
"confirm_withdrawal",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
props,
br_code=BRT_Other,
)
@ -752,17 +742,17 @@ def _format_stake_credential(
if path:
return (
f"{TR.tr('cardano__for_account')} {format_account_number(path)}:",
f"{TR.cardano__for_account} {format_account_number(path)}:",
address_n_to_str(to_account_path(path)),
)
elif key_hash:
return (
TR.tr("cardano__for_key_hash"),
TR.cardano__for_key_hash,
bech32.encode(bech32.HRP_STAKE_KEY_HASH, key_hash),
)
elif script_hash:
return (
TR.tr("cardano__for_script"),
TR.cardano__for_script,
bech32.encode(bech32.HRP_SCRIPT_HASH, script_hash),
)
else:
@ -775,15 +765,15 @@ async def confirm_cvote_registration_delegation(
weight: int,
) -> None:
props: list[PropertyType] = [
(TR.tr("cardano__vote_key_registration"), None),
(TR.tr("cardano__delegating_to"), public_key),
(TR.cardano__vote_key_registration, None),
(TR.cardano__delegating_to, public_key),
]
if weight is not None:
props.append((TR.tr("cardano__weight"), str(weight)))
props.append((TR.cardano__weight, str(weight)))
await confirm_properties(
"confirm_cvote_registration_delegation",
title=TR.tr("cardano__confirm_transaction"),
title=TR.cardano__confirm_transaction,
props=props,
br_code=ButtonRequestType.Other,
)
@ -794,14 +784,14 @@ async def confirm_cvote_registration_payment_address(
should_show_payment_warning: bool,
) -> None:
props = [
(TR.tr("cardano__vote_key_registration"), None),
(TR.tr("cardano__rewards_go_to"), payment_address),
(TR.cardano__vote_key_registration, None),
(TR.cardano__rewards_go_to, payment_address),
]
if should_show_payment_warning:
props.append((CVOTE_REWARD_ELIGIBILITY_WARNING, None))
await confirm_properties(
"confirm_cvote_registration_payment_address",
title=TR.tr("cardano__confirm_transaction"),
title=TR.cardano__confirm_transaction,
props=props,
br_code=ButtonRequestType.Other,
)
@ -813,31 +803,31 @@ async def confirm_cvote_registration(
nonce: int,
voting_purpose: int | None,
) -> None:
props: list[PropertyType] = [(TR.tr("cardano__vote_key_registration"), None)]
props: list[PropertyType] = [(TR.cardano__vote_key_registration, None)]
if vote_public_key is not None:
props.append((TR.tr("cardano__vote_public_key"), vote_public_key))
props.append((TR.cardano__vote_public_key, vote_public_key))
props.extend(
[
(
f"{TR.tr('cardano__staking_key_for_account')} {format_account_number(staking_path)}:",
f"{TR.cardano__staking_key_for_account} {format_account_number(staking_path)}:",
address_n_to_str(staking_path),
),
(TR.tr("cardano__nonce"), str(nonce)),
(TR.cardano__nonce, str(nonce)),
]
)
if voting_purpose is not None:
props.append(
(
TR.tr("cardano__voting_purpose"),
TR.tr("cardano__catalyst")
TR.cardano__voting_purpose,
TR.cardano__catalyst
if voting_purpose == 0
else f"{voting_purpose} ({TR.tr('cardano__other')})",
else f"{voting_purpose} ({TR.cardano__other})",
)
)
await confirm_properties(
"confirm_cvote_registration",
title=TR.tr("cardano__confirm_transaction"),
title=TR.cardano__confirm_transaction,
props=props,
br_code=ButtonRequestType.Other,
)
@ -846,8 +836,8 @@ async def confirm_cvote_registration(
async def show_auxiliary_data_hash(auxiliary_data_hash: bytes) -> None:
await confirm_properties(
"confirm_auxiliary_data",
TR.tr("cardano__confirm_transaction"),
((TR.tr("cardano__auxiliary_data_hash"), auxiliary_data_hash),),
TR.cardano__confirm_transaction,
((TR.cardano__auxiliary_data_hash, auxiliary_data_hash),),
br_code=BRT_Other,
)
@ -856,19 +846,19 @@ async def confirm_token_minting(policy_id: bytes, token: messages.CardanoToken)
assert token.mint_amount is not None # _validate_token
await confirm_properties(
"confirm_mint",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
TR.tr("cardano__asset_fingerprint"),
TR.cardano__asset_fingerprint,
format_asset_fingerprint(
policy_id,
token.asset_name_bytes,
),
),
(
TR.tr("cardano__amount_minted")
TR.cardano__amount_minted
if token.mint_amount >= 0
else TR.tr("cardano__amount_burned"),
else TR.cardano__amount_burned,
format_amount(token.mint_amount, 0),
),
),
@ -879,8 +869,8 @@ async def confirm_token_minting(policy_id: bytes, token: messages.CardanoToken)
async def warn_tx_network_unverifiable() -> None:
await confirm_metadata(
"warning_no_outputs",
TR.tr("cardano__warning"),
TR.tr("cardano__no_output_tx"),
TR.cardano__warning,
TR.cardano__no_output_tx,
br_code=BRT_Other,
)
@ -888,10 +878,10 @@ async def warn_tx_network_unverifiable() -> None:
async def confirm_script_data_hash(script_data_hash: bytes) -> None:
await confirm_properties(
"confirm_script_data_hash",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(
TR.tr("cardano__script_data_hash"),
TR.cardano__script_data_hash,
bech32.encode(bech32.HRP_SCRIPT_DATA_HASH, script_data_hash),
),
),
@ -904,11 +894,11 @@ async def confirm_collateral_input(
) -> None:
await confirm_properties(
"confirm_collateral_input",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(TR.tr("cardano__collateral_input_id"), collateral_input.prev_hash),
(TR.cardano__collateral_input_id, collateral_input.prev_hash),
(
TR.tr("cardano__collateral_input_index"),
TR.cardano__collateral_input_index,
str(collateral_input.prev_index),
),
),
@ -921,10 +911,10 @@ async def confirm_reference_input(
) -> None:
await confirm_properties(
"confirm_reference_input",
TR.tr("cardano__confirm_transaction"),
TR.cardano__confirm_transaction,
(
(TR.tr("cardano__reference_input_id"), reference_input.prev_hash),
(TR.tr("cardano__reference_input_index"), str(reference_input.prev_index)),
(TR.cardano__reference_input_id, reference_input.prev_hash),
(TR.cardano__reference_input_index, str(reference_input.prev_index)),
),
br_code=BRT_Other,
)
@ -944,8 +934,8 @@ async def confirm_required_signer(
await confirm_properties(
"confirm_required_signer",
TR.tr("cardano__confirm_transaction"),
((TR.tr("cardano__required_signer"), formatted_signer),),
TR.cardano__confirm_transaction,
((TR.cardano__required_signer, formatted_signer),),
br_code=BRT_Other,
)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.wire import ProcessError
from .signer import Signer
@ -14,7 +14,7 @@ class MultisigSigner(Signer):
The multisig signing mode only allows signing with multisig (and minting) keys.
"""
SIGNING_MODE_TITLE = TR.tr("cardano__confirming_a_multisig_transaction")
SIGNING_MODE_TITLE = TR.cardano__confirming_a_multisig_transaction
def _validate_tx_init(self) -> None:
msg = self.msg # local_cache_attribute

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.wire import ProcessError
from .. import layout
@ -17,7 +17,7 @@ class OrdinarySigner(Signer):
controlled by 1852' keys, dealing with staking and minting/burning tokens.
"""
SIGNING_MODE_TITLE = TR.tr("cardano__confirming_transction")
SIGNING_MODE_TITLE = TR.cardano__confirming_transction
def _validate_tx_init(self) -> None:
msg = self.msg # local_cache_attribute

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.wire import ProcessError
from .signer import Signer
@ -22,7 +22,7 @@ class PoolOwnerSigner(Signer):
staking key in the list of pool owners.
"""
SIGNING_MODE_TITLE = TR.tr("cardano__confirming_pool_registration")
SIGNING_MODE_TITLE = TR.cardano__confirming_pool_registration
def _validate_tx_init(self) -> None:
msg = self.msg # local_cache_attribute

@ -30,7 +30,7 @@ async def get() -> str:
async def _request_on_host() -> str:
import trezortranslate as TR
from trezortranslate import TR
from trezor.messages import PassphraseAck, PassphraseRequest
from trezor.ui.layouts import request_passphrase_on_host
from trezor.wire.context import call
@ -61,20 +61,20 @@ async def _request_on_host() -> str:
if storage_device.get_hide_passphrase_from_host():
await confirm_action(
"passphrase_host1_hidden",
TR.tr("passphrase__hidden_wallet"),
description=f"{TR.tr('passphrase__access_hidden_wallet')}\n{TR.tr('passphrase__from_host_not_shown')}",
TR.passphrase__hidden_wallet,
description=f"{TR.passphrase__access_hidden_wallet}\n{TR.passphrase__from_host_not_shown}",
)
else:
await confirm_action(
"passphrase_host1",
TR.tr("passphrase__hidden_wallet"),
description=TR.tr("passphrase__next_screen_will_show_passphrase"),
verb=TR.tr("buttons__continue"),
TR.passphrase__hidden_wallet,
description=TR.passphrase__next_screen_will_show_passphrase,
verb=TR.buttons__continue,
)
await confirm_blob(
"passphrase_host2",
TR.tr("passphrase__title_confirm"),
TR.passphrase__title_confirm,
passphrase,
)

@ -2,7 +2,7 @@ import utime
from typing import Any, NoReturn
import storage.cache as storage_cache
import trezortranslate as TR
from trezortranslate import TR
from trezor import config, utils, wire
from trezor.ui.layouts import show_error_and_raise
@ -54,9 +54,9 @@ async def request_pin_confirm(*args: Any, **kwargs: Any) -> str:
from trezor.ui.layouts import confirm_reenter_pin, pin_mismatch_popup
while True:
pin1 = await request_pin(TR.tr("pin__enter_new"), *args, **kwargs)
pin1 = await request_pin(TR.pin__enter_new, *args, **kwargs)
await confirm_reenter_pin()
pin2 = await request_pin(TR.tr("pin__reenter_new"), *args, **kwargs)
pin2 = await request_pin(TR.pin__reenter_new, *args, **kwargs)
if pin1 == pin2:
return pin1
await pin_mismatch_popup()
@ -81,7 +81,7 @@ def _set_last_unlock_time() -> None:
storage_cache.set_int(storage_cache.APP_COMMON_REQUEST_PIN_LAST_UNLOCK, now)
_DEF_ARG_PIN_ENTER: str = TR.tr("pin__enter")
_DEF_ARG_PIN_ENTER: str = TR.pin__enter
async def verify_user_pin(
@ -120,7 +120,7 @@ async def verify_user_pin(
while retry:
pin = await request_pin_on_device( # type: ignore ["request_pin_on_device" is possibly unbound]
TR.tr("pin__enter"), config.get_pin_rem(), allow_cancel, wrong_pin=True
TR.pin__enter, config.get_pin_rem(), allow_cancel, wrong_pin=True
)
if config.unlock(pin, salt):
_set_last_unlock_time()
@ -132,8 +132,8 @@ async def verify_user_pin(
async def error_pin_invalid() -> NoReturn:
await show_error_and_raise(
"warning_wrong_pin",
TR.tr("pin__entered_not_valid"),
TR.tr("pin__wrong_pin"), # header
TR.pin__entered_not_valid,
TR.pin__wrong_pin, # header
exc=wire.PinInvalid,
)
assert False
@ -142,8 +142,8 @@ async def error_pin_invalid() -> NoReturn:
async def error_pin_matches_wipe_code() -> NoReturn:
await show_error_and_raise(
"warning_invalid_new_pin",
TR.tr("pin__diff_from_wipe_code"),
TR.tr("pin__invalid_pin"), # header
TR.pin__diff_from_wipe_code,
TR.pin__invalid_pin, # header
exc=wire.PinInvalid,
)
assert False

@ -1,4 +1,4 @@
import trezortranslate as TR
from trezortranslate import TR
from storage.sd_salt import SD_CARD_HOT_SWAPPABLE
from trezor import io, wire
from trezor.ui.layouts import confirm_action, show_error_and_raise
@ -12,18 +12,18 @@ async def _confirm_retry_wrong_card() -> None:
if SD_CARD_HOT_SWAPPABLE:
await confirm_action(
"warning_wrong_sd",
TR.tr("sd_card__title"),
TR.tr("sd_card__wrong_sd_card"),
TR.tr("sd_card__insert_correct_card"),
verb=TR.tr("buttons__retry"),
verb_cancel=TR.tr("buttons__abort"),
TR.sd_card__title,
TR.sd_card__wrong_sd_card,
TR.sd_card__insert_correct_card,
verb=TR.buttons__retry,
verb_cancel=TR.buttons__abort,
exc=SdCardUnavailable("Wrong SD card."),
)
else:
await show_error_and_raise(
"warning_wrong_sd",
TR.tr("sd_card__unplug_and_insert_correct"),
TR.tr("sd_card__wrong_sd_card"),
TR.sd_card__unplug_and_insert_correct,
TR.sd_card__wrong_sd_card,
exc=SdCardUnavailable("Wrong SD card."),
)
@ -32,18 +32,18 @@ async def _confirm_retry_insert_card() -> None:
if SD_CARD_HOT_SWAPPABLE:
await confirm_action(
"warning_no_sd",
TR.tr("sd_card__title"),
TR.tr("sd_card__card_required"),
TR.tr("sd_card__please_insert"),
verb=TR.tr("buttons__retry"),
verb_cancel=TR.tr("buttons__abort"),
TR.sd_card__title,
TR.sd_card__card_required,
TR.sd_card__please_insert,
verb=TR.buttons__retry,
verb_cancel=TR.buttons__abort,
exc=SdCardUnavailable("SD card required."),
)
else:
await show_error_and_raise(
"warning_no_sd",
TR.tr("sd_card__please_unplug_and_insert"),
TR.tr("sd_card__card_required"),
TR.sd_card__please_unplug_and_insert,
TR.sd_card__card_required,
exc=SdCardUnavailable("SD card required."),
)
@ -52,22 +52,22 @@ async def _confirm_format_card() -> None:
# Format card? yes/no
await confirm_action(
"warning_format_sd",
TR.tr("sd_card__error"),
TR.tr("sd_card__unknown_filesystem"),
TR.tr("sd_card__use_different_card"),
verb=TR.tr("buttons__format"),
verb_cancel=TR.tr("buttons__cancel"),
TR.sd_card__error,
TR.sd_card__unknown_filesystem,
TR.sd_card__use_different_card,
verb=TR.buttons__format,
verb_cancel=TR.buttons__cancel,
exc=SdCardUnavailable("SD card not formatted."),
)
# Confirm formatting
await confirm_action(
"confirm_format_sd",
TR.tr("sd_card__format_card"),
TR.tr("sd_card__all_data_will_be_lost"),
TR.tr("sd_card__wanna_format"),
TR.sd_card__format_card,
TR.sd_card__all_data_will_be_lost,
TR.sd_card__wanna_format,
reverse=True,
verb=TR.tr("sd_card__format_card"),
verb=TR.sd_card__format_card,
hold=True,
exc=SdCardUnavailable("SD card not formatted."),
)
@ -78,11 +78,11 @@ async def confirm_retry_sd(
) -> None:
await confirm_action(
"warning_sd_retry",
TR.tr("sd_card__title_problem"),
TR.sd_card__title_problem,
None,
TR.tr("sd_card__problem_accessing"),
verb=TR.tr("buttons__retry"),
verb_cancel=TR.tr("buttons__abort"),
TR.sd_card__problem_accessing,
verb=TR.buttons__retry,
verb_cancel=TR.buttons__abort,
exc=exc,
)

@ -6,7 +6,7 @@ if TYPE_CHECKING:
async def load_device(msg: LoadDevice) -> Success:
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor import config
from trezor.crypto import bip39, slip39
from trezor.enums import BackupType
@ -40,9 +40,9 @@ async def load_device(msg: LoadDevice) -> Success:
# _warn
await confirm_action(
"warn_loading_seed",
TR.tr("debug__loading_seed"),
TR.tr("debug__loading_seed_not_recommended"),
TR.tr("words__know_what_your_doing"),
TR.debug__loading_seed,
TR.debug__loading_seed_not_recommended,
TR.words__know_what_your_doing,
)
# END _warn

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_properties
@ -52,11 +52,11 @@ async def _confirm_properties(
async def confirm_action_buyram(msg: EosActionBuyRam) -> None:
await _confirm_properties(
"confirm_buyram",
TR.tr("eos__buy_ram"),
TR.eos__buy_ram,
(
(TR.tr("eos__payer"), eos_name_to_string(msg.payer)),
(TR.tr("eos__receiver"), eos_name_to_string(msg.receiver)),
(TR.tr("eos__amount"), eos_asset_to_string(msg.quantity)),
(TR.eos__payer, eos_name_to_string(msg.payer)),
(TR.eos__receiver, eos_name_to_string(msg.receiver)),
(TR.eos__amount, eos_asset_to_string(msg.quantity)),
),
)
@ -64,32 +64,32 @@ async def confirm_action_buyram(msg: EosActionBuyRam) -> None:
async def confirm_action_buyrambytes(msg: EosActionBuyRamBytes) -> None:
await _confirm_properties(
"confirm_buyrambytes",
TR.tr("eos__buy_ram"),
TR.eos__buy_ram,
(
(TR.tr("eos__payer"), eos_name_to_string(msg.payer)),
(TR.tr("eos__receiver"), eos_name_to_string(msg.receiver)),
(TR.tr("eos__bytes"), str(msg.bytes)),
(TR.eos__payer, eos_name_to_string(msg.payer)),
(TR.eos__receiver, eos_name_to_string(msg.receiver)),
(TR.eos__bytes, str(msg.bytes)),
),
)
async def confirm_action_delegate(msg: EosActionDelegate) -> None:
props = [
(TR.tr("eos__sender"), eos_name_to_string(msg.sender)),
(TR.tr("eos__receiver"), eos_name_to_string(msg.receiver)),
(TR.tr("eos__cpu"), eos_asset_to_string(msg.cpu_quantity)),
(TR.tr("eos__net"), eos_asset_to_string(msg.net_quantity)),
(TR.eos__sender, eos_name_to_string(msg.sender)),
(TR.eos__receiver, eos_name_to_string(msg.receiver)),
(TR.eos__cpu, eos_asset_to_string(msg.cpu_quantity)),
(TR.eos__net, eos_asset_to_string(msg.net_quantity)),
]
append = props.append # local_cache_attribute
if msg.transfer:
append((TR.tr("eos__transfer"), TR.tr("eos__yes")))
append((TR.tr("eos__receiver"), eos_name_to_string(msg.receiver)))
append((TR.eos__transfer, TR.eos__yes))
append((TR.eos__receiver, eos_name_to_string(msg.receiver)))
else:
append((TR.tr("eos__transfer"), TR.tr("eos__no")))
append((TR.eos__transfer, TR.eos__no))
await _confirm_properties(
"confirm_delegate",
TR.tr("eos__delegate"),
TR.eos__delegate,
props,
)
@ -97,10 +97,10 @@ async def confirm_action_delegate(msg: EosActionDelegate) -> None:
async def confirm_action_sellram(msg: EosActionSellRam) -> None:
await _confirm_properties(
"confirm_sellram",
TR.tr("eos__sell_ram"),
TR.eos__sell_ram,
(
(TR.tr("eos__receiver"), eos_name_to_string(msg.account)),
(TR.tr("eos__bytes"), str(msg.bytes)),
(TR.eos__receiver, eos_name_to_string(msg.account)),
(TR.eos__bytes, str(msg.bytes)),
),
)
@ -108,12 +108,12 @@ async def confirm_action_sellram(msg: EosActionSellRam) -> None:
async def confirm_action_undelegate(msg: EosActionUndelegate) -> None:
await _confirm_properties(
"confirm_undelegate",
TR.tr("eos__undelegate"),
TR.eos__undelegate,
(
(TR.tr("eos__sender"), eos_name_to_string(msg.sender)),
(TR.tr("eos__receiver"), eos_name_to_string(msg.receiver)),
(TR.tr("eos__cpu"), eos_asset_to_string(msg.cpu_quantity)),
(TR.tr("eos__net"), eos_asset_to_string(msg.net_quantity)),
(TR.eos__sender, eos_name_to_string(msg.sender)),
(TR.eos__receiver, eos_name_to_string(msg.receiver)),
(TR.eos__cpu, eos_asset_to_string(msg.cpu_quantity)),
(TR.eos__net, eos_asset_to_string(msg.net_quantity)),
),
)
@ -121,8 +121,8 @@ async def confirm_action_undelegate(msg: EosActionUndelegate) -> None:
async def confirm_action_refund(msg: EosActionRefund) -> None:
await _confirm_properties(
"confirm_refund",
TR.tr("eos__refund"),
((TR.tr("eos__owner"), eos_name_to_string(msg.owner)),),
TR.eos__refund,
((TR.eos__owner, eos_name_to_string(msg.owner)),),
)
@ -133,10 +133,10 @@ async def confirm_action_voteproducer(msg: EosActionVoteProducer) -> None:
# PROXY
await _confirm_properties(
"confirm_voteproducer",
TR.tr("eos__vote_for_proxy"),
TR.eos__vote_for_proxy,
(
(TR.tr("eos__voter"), eos_name_to_string(msg.voter)),
(TR.tr("eos__proxy"), eos_name_to_string(msg.proxy)),
(TR.eos__voter, eos_name_to_string(msg.voter)),
(TR.eos__proxy, eos_name_to_string(msg.proxy)),
),
)
@ -144,7 +144,7 @@ async def confirm_action_voteproducer(msg: EosActionVoteProducer) -> None:
# PRODUCERS
await _confirm_properties(
"confirm_voteproducer",
TR.tr("eos__vote_for_producers"),
TR.eos__vote_for_producers,
(
(f"{wi:2d}. {eos_name_to_string(producer)}", None)
for wi, producer in enumerate(producers, 1)
@ -155,37 +155,37 @@ async def confirm_action_voteproducer(msg: EosActionVoteProducer) -> None:
# Cancel vote
await _confirm_properties(
"confirm_voteproducer",
TR.tr("eos__cancel_vote"),
((TR.tr("eos__voter"), eos_name_to_string(msg.voter)),),
TR.eos__cancel_vote,
((TR.eos__voter, eos_name_to_string(msg.voter)),),
)
async def confirm_action_transfer(msg: EosActionTransfer, account: str) -> None:
props = [
(TR.tr("eos__from"), eos_name_to_string(msg.sender)),
(TR.tr("eos__to"), eos_name_to_string(msg.receiver)),
(TR.tr("eos__amount"), eos_asset_to_string(msg.quantity)),
(TR.tr("eos__contract"), account),
(TR.eos__from, eos_name_to_string(msg.sender)),
(TR.eos__to, eos_name_to_string(msg.receiver)),
(TR.eos__amount, eos_asset_to_string(msg.quantity)),
(TR.eos__contract, account),
]
if msg.memo is not None:
props.append((TR.tr("eos__memo"), msg.memo[:512]))
props.append((TR.eos__memo, msg.memo[:512]))
await _confirm_properties(
"confirm_transfer",
TR.tr("eos__transfer").replace(":", ""),
TR.eos__transfer.replace(":", ""),
props,
)
async def confirm_action_updateauth(msg: EosActionUpdateAuth) -> None:
props: list[PropertyType] = [
(TR.tr("eos__account"), eos_name_to_string(msg.account)),
(TR.tr("eos__permission"), eos_name_to_string(msg.permission)),
(TR.tr("eos__parent"), eos_name_to_string(msg.parent)),
(TR.eos__account, eos_name_to_string(msg.account)),
(TR.eos__permission, eos_name_to_string(msg.permission)),
(TR.eos__parent, eos_name_to_string(msg.parent)),
]
props.extend(authorization_fields(msg.auth))
await _confirm_properties(
"confirm_updateauth",
TR.tr("eos__update_auth"),
TR.eos__update_auth,
props,
)
@ -193,10 +193,10 @@ async def confirm_action_updateauth(msg: EosActionUpdateAuth) -> None:
async def confirm_action_deleteauth(msg: EosActionDeleteAuth) -> None:
await _confirm_properties(
"confirm_deleteauth",
TR.tr("eos__delete_auth"),
TR.eos__delete_auth,
(
(TR.tr("eos__account"), eos_name_to_string(msg.account)),
(TR.tr("eos__permission"), eos_name_to_string(msg.permission)),
(TR.eos__account, eos_name_to_string(msg.account)),
(TR.eos__permission, eos_name_to_string(msg.permission)),
),
)
@ -204,12 +204,12 @@ async def confirm_action_deleteauth(msg: EosActionDeleteAuth) -> None:
async def confirm_action_linkauth(msg: EosActionLinkAuth) -> None:
await _confirm_properties(
"confirm_linkauth",
TR.tr("eos__link_auth"),
TR.eos__link_auth,
(
(TR.tr("eos__account"), eos_name_to_string(msg.account)),
(TR.tr("eos__code"), eos_name_to_string(msg.code)),
(TR.tr("eos__type"), eos_name_to_string(msg.type)),
(TR.tr("eos__requirement"), eos_name_to_string(msg.requirement)),
(TR.eos__account, eos_name_to_string(msg.account)),
(TR.eos__code, eos_name_to_string(msg.code)),
(TR.eos__type, eos_name_to_string(msg.type)),
(TR.eos__requirement, eos_name_to_string(msg.requirement)),
),
)
@ -217,25 +217,25 @@ async def confirm_action_linkauth(msg: EosActionLinkAuth) -> None:
async def confirm_action_unlinkauth(msg: EosActionUnlinkAuth) -> None:
await _confirm_properties(
"confirm_unlinkauth",
TR.tr("eos__unlink_auth"),
TR.eos__unlink_auth,
(
(TR.tr("eos__account"), eos_name_to_string(msg.account)),
(TR.tr("eos__code"), eos_name_to_string(msg.code)),
(TR.tr("eos__type"), eos_name_to_string(msg.type)),
(TR.eos__account, eos_name_to_string(msg.account)),
(TR.eos__code, eos_name_to_string(msg.code)),
(TR.eos__type, eos_name_to_string(msg.type)),
),
)
async def confirm_action_newaccount(msg: EosActionNewAccount) -> None:
props: list[PropertyType] = [
(TR.tr("eos__creator"), eos_name_to_string(msg.creator)),
(TR.tr("eos__name"), eos_name_to_string(msg.name)),
(TR.eos__creator, eos_name_to_string(msg.creator)),
(TR.eos__name, eos_name_to_string(msg.name)),
]
props.extend(authorization_fields(msg.owner))
props.extend(authorization_fields(msg.active))
await _confirm_properties(
"confirm_newaccount",
TR.tr("eos__new_account"),
TR.eos__new_account,
props,
)
@ -243,11 +243,11 @@ async def confirm_action_newaccount(msg: EosActionNewAccount) -> None:
async def confirm_action_unknown(action: EosActionCommon, checksum: bytes) -> None:
await confirm_properties(
"confirm_unknown",
TR.tr("eos__arbitrary_data"),
TR.eos__arbitrary_data,
(
(TR.tr("eos__contract"), eos_name_to_string(action.account)),
(TR.tr("eos__action_name"), eos_name_to_string(action.name)),
(TR.tr("eos__checksum"), checksum),
(TR.eos__contract, eos_name_to_string(action.account)),
(TR.eos__action_name, eos_name_to_string(action.name)),
(TR.eos__checksum, checksum),
),
hold=is_last,
br_code=ButtonRequestType.ConfirmOutput,
@ -262,7 +262,7 @@ def authorization_fields(auth: EosAuthorization) -> list[PropertyType]:
fields: list[PropertyType] = []
append = fields.append # local_cache_attribute
append((TR.tr("eos__threshold"), str(auth.threshold)))
append((TR.eos__threshold, str(auth.threshold)))
# NOTE: getting rid of f-strings saved almost 100 bytes

@ -7,15 +7,15 @@ async def require_get_public_key(
async def require_sign_tx(num_actions: int) -> None:
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.strings import format_plural
from trezor.ui.layouts import confirm_action
await confirm_action(
"confirm_tx",
TR.tr("eos__sign_transaction"),
description=TR.tr("eos__about_to_sign_template"),
TR.eos__sign_transaction,
description=TR.eos__about_to_sign_template,
# TODO: handle translation
description_param=format_plural("{count} {plural}", num_actions, "action"),
br_code=ButtonRequestType.SignTx,

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor import ui
from trezor.enums import ButtonRequestType
from trezor.strings import format_plural
@ -35,16 +35,16 @@ async def require_confirm_tx(
if to_bytes:
to_str = address_from_bytes(to_bytes, network)
else:
to_str = TR.tr("ethereum__new_contract")
to_str = TR.ethereum__new_contract
total_amount = format_ethereum_amount(value, token, network)
maximum_fee = format_ethereum_amount(gas_price * gas_limit, None, network)
gas_limit_str = TR.tr("ethereum__units_template").format(gas_limit)
gas_limit_str = TR.ethereum__units_template.format(gas_limit)
gas_price_str = format_ethereum_amount(gas_price, None, network)
items = (
(TR.tr("ethereum__gas_limit"), gas_limit_str),
(TR.tr("ethereum__gas_price"), gas_price_str),
(TR.ethereum__gas_limit, gas_limit_str),
(TR.ethereum__gas_price, gas_price_str),
)
await confirm_ethereum_tx(to_str, total_amount, maximum_fee, items)
@ -63,18 +63,18 @@ async def require_confirm_tx_eip1559(
if to_bytes:
to_str = address_from_bytes(to_bytes, network)
else:
to_str = TR.tr("ethereum__new_contract")
to_str = TR.ethereum__new_contract
total_amount = format_ethereum_amount(value, token, network)
maximum_fee = format_ethereum_amount(max_gas_fee * gas_limit, None, network)
gas_limit_str = TR.tr("ethereum__units_template").format(gas_limit)
gas_limit_str = TR.ethereum__units_template.format(gas_limit)
max_gas_fee_str = format_ethereum_amount(max_gas_fee, None, network)
max_priority_fee_str = format_ethereum_amount(max_priority_fee, None, network)
items = (
(TR.tr("ethereum__gas_limit"), gas_limit_str),
(TR.tr("ethereum__max_gas_price"), max_gas_fee_str),
(TR.tr("ethereum__priority_fee"), max_priority_fee_str),
(TR.ethereum__gas_limit, gas_limit_str),
(TR.ethereum__max_gas_price, max_gas_fee_str),
(TR.ethereum__priority_fee, max_priority_fee_str),
)
await confirm_ethereum_tx(to_str, total_amount, maximum_fee, items)
@ -87,9 +87,9 @@ def require_confirm_unknown_token(address_bytes: bytes) -> Awaitable[None]:
contract_address_hex = "0x" + hexlify(address_bytes).decode()
return confirm_address(
TR.tr("ethereum__unknown_token"),
TR.ethereum__unknown_token,
contract_address_hex,
TR.tr("ethereum__contract"),
TR.ethereum__contract,
"unknown_token",
br_code=ButtonRequestType.SignTx,
)
@ -102,7 +102,7 @@ def require_confirm_address(address_bytes: bytes) -> Awaitable[None]:
address_hex = "0x" + hexlify(address_bytes).decode()
return confirm_address(
TR.tr("ethereum__title_signing_address"),
TR.ethereum__title_signing_address,
address_hex,
br_code=ButtonRequestType.SignTx,
)
@ -111,9 +111,9 @@ def require_confirm_address(address_bytes: bytes) -> Awaitable[None]:
def require_confirm_data(data: bytes, data_total: int) -> Awaitable[None]:
return confirm_blob(
"confirm_data",
TR.tr("ethereum__title_confirm_data"),
TR.ethereum__title_confirm_data,
data,
TR.tr("ethereum__data_size_template").format(data_total),
TR.ethereum__data_size_template.format(data_total),
br_code=ButtonRequestType.SignTx,
ask_pagination=True,
)
@ -124,9 +124,9 @@ async def confirm_typed_data_final() -> None:
await confirm_action(
"confirm_typed_data_final",
TR.tr("ethereum__title_confirm_typed_data"),
TR.tr("ethereum__sign_eip712"),
verb=TR.tr("buttons__hold_to_confirm"),
TR.ethereum__title_confirm_typed_data,
TR.ethereum__sign_eip712,
verb=TR.buttons__hold_to_confirm,
hold=True,
)
@ -134,9 +134,9 @@ async def confirm_typed_data_final() -> None:
def confirm_empty_typed_message() -> Awaitable[None]:
return confirm_text(
"confirm_empty_typed_message",
TR.tr("ethereum__title_confirm_message"),
TR.ethereum__title_confirm_message,
"",
TR.tr("ethereum__no_message_field"),
TR.ethereum__no_message_field,
)
@ -145,14 +145,14 @@ async def should_show_domain(name: bytes, version: bytes) -> bool:
domain_version = decode_typed_data(version, "string")
para = (
(ui.NORMAL, TR.tr("ethereum__name_and_version")),
(ui.NORMAL, TR.ethereum__name_and_version),
(ui.DEMIBOLD, domain_name),
(ui.DEMIBOLD, domain_version),
)
return await should_show_more(
TR.tr("ethereum__title_confirm_domain"),
TR.ethereum__title_confirm_domain,
para,
TR.tr("ethereum__show_full_domain"),
TR.ethereum__show_full_domain,
"should_show_domain",
)
@ -163,8 +163,8 @@ async def should_show_struct(
title: str | None = None,
button_text: str | None = None,
) -> bool:
title = title or TR.tr("ethereum__title_confirm_struct") # def_arg
button_text = button_text or TR.tr("ethereum__show_full_struct") # def_arg
title = title or TR.ethereum__title_confirm_struct # def_arg
button_text = button_text or TR.ethereum__show_full_struct # def_arg
para = (
(ui.DEMIBOLD, description),
(
@ -191,7 +191,7 @@ async def should_show_array(
return await should_show_more(
limit_str(".".join(parent_objects)),
para,
TR.tr("ethereum__show_full_array"),
TR.ethereum__show_full_array,
"should_show_array",
)

@ -67,7 +67,7 @@ async def _generate_typed_data_hash(
metamask_v4_compat - a flag that enables compatibility with MetaMask's signTypedData_v4 method
"""
import trezortranslate as TR
from trezortranslate import TR
from .layout import (
confirm_empty_typed_message,
@ -100,8 +100,8 @@ async def _generate_typed_data_hash(
show_message = await should_show_struct(
primary_type,
typed_data_envelope.types[primary_type].members,
TR.tr("ethereum__title_confirm_message"),
TR.tr("ethereum__show_full_message"),
TR.ethereum__title_confirm_message,
TR.ethereum__show_full_message,
)
message_hash = await typed_data_envelope.hash_struct(
primary_type,

@ -5,7 +5,7 @@ if TYPE_CHECKING:
async def verify_message(msg: EthereumVerifyMessage) -> Success:
import trezortranslate as TR
from trezortranslate import TR
from trezor.crypto.curve import secp256k1
from trezor.crypto.hashlib import sha3_256
from trezor.messages import Success
@ -37,5 +37,5 @@ async def verify_message(msg: EthereumVerifyMessage) -> Success:
await confirm_signverify("ETH", decode_message(msg.message), address, verify=True)
await show_success("verify_message", TR.tr("ethereum__valid_signature"))
await show_success("verify_message", TR.ethereum__valid_signature)
return Success(message="Message verified")

@ -14,7 +14,7 @@ async def busyscreen() -> None:
async def homescreen() -> None:
import trezortranslate as TR
from trezortranslate import TR
if storage.device.is_initialized():
label = storage.device.get_label()
@ -24,19 +24,19 @@ async def homescreen() -> None:
notification = None
notification_is_error = False
if is_set_any_session(MessageType.AuthorizeCoinJoin):
notification = TR.tr("homescreen__title_coinjoin_authorized")
notification = TR.homescreen__title_coinjoin_authorized
elif storage.device.is_initialized() and storage.device.no_backup():
notification = TR.tr("homescreen__title_seedless")
notification = TR.homescreen__title_seedless
notification_is_error = True
elif storage.device.is_initialized() and storage.device.unfinished_backup():
notification = TR.tr("homescreen__title_backup_failed")
notification = TR.homescreen__title_backup_failed
notification_is_error = True
elif storage.device.is_initialized() and storage.device.needs_backup():
notification = TR.tr("homescreen__title_backup_needed")
notification = TR.homescreen__title_backup_needed
elif storage.device.is_initialized() and not config.has_pin():
notification = TR.tr("homescreen__title_pin_not_set")
notification = TR.homescreen__title_pin_not_set
elif storage.device.get_experimental_features():
notification = TR.tr("homescreen__title_experimental_mode")
notification = TR.homescreen__title_experimental_mode
await Homescreen(
label=label,

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor import utils
from trezor.enums import ButtonRequestType
@ -163,19 +163,19 @@ async def _require_confirm_change_label(label: str) -> None:
await confirm_single(
"set_label",
TR.tr("device_name__title"),
description=TR.tr("device_name__change_template"),
TR.device_name__title,
description=TR.device_name__change_template,
description_param=label,
verb=TR.tr("buttons__change"),
verb=TR.buttons__change,
)
async def _require_confirm_change_passphrase(use: bool) -> None:
description = TR.tr("passphrase__turn_on") if use else TR.tr("passphrase__turn_off")
verb = TR.tr("buttons__turn_on") if use else TR.tr("buttons__turn_off")
description = TR.passphrase__turn_on if use else TR.passphrase__turn_off
verb = TR.buttons__turn_on if use else TR.buttons__turn_off
await confirm_action(
"set_passphrase",
TR.tr("passphrase__title_settings"),
TR.passphrase__title_settings,
description=description,
verb=verb,
br_code=BRT_PROTECT_CALL,
@ -186,13 +186,13 @@ async def _require_confirm_change_passphrase_source(
passphrase_always_on_device: bool,
) -> None:
description = (
TR.tr("passphrase__always_on_device")
TR.passphrase__always_on_device
if passphrase_always_on_device
else TR.tr("passphrase__revoke_on_device")
else TR.passphrase__revoke_on_device
)
await confirm_action(
"set_passphrase_source",
TR.tr("passphrase__title_source"),
TR.passphrase__title_source,
description=description,
br_code=BRT_PROTECT_CALL,
)
@ -200,20 +200,20 @@ async def _require_confirm_change_passphrase_source(
async def _require_confirm_change_display_rotation(rotation: int) -> None:
if rotation == 0:
label = TR.tr("rotation__north")
label = TR.rotation__north
elif rotation == 90:
label = TR.tr("rotation__east")
label = TR.rotation__east
elif rotation == 180:
label = TR.tr("rotation__south")
label = TR.rotation__south
elif rotation == 270:
label = TR.tr("rotation__west")
label = TR.rotation__west
else:
raise DataError("Unsupported display rotation")
await confirm_action(
"set_rotation",
TR.tr("rotation__title_change"),
description=TR.tr("rotation__change_template"),
TR.rotation__title_change,
description=TR.rotation__change_template,
description_param=label,
br_code=BRT_PROTECT_CALL,
)
@ -224,8 +224,8 @@ async def _require_confirm_change_autolock_delay(delay_ms: int) -> None:
await confirm_action(
"set_autolock_delay",
TR.tr("auto_lock__title"),
description=TR.tr("auto_lock__change_template"),
TR.auto_lock__title,
description=TR.auto_lock__change_template,
description_param=format_duration_ms(delay_ms),
br_code=BRT_PROTECT_CALL,
)
@ -237,23 +237,23 @@ async def _require_confirm_safety_checks(level: SafetyCheckLevel) -> None:
if level == SafetyCheckLevel.Strict:
await confirm_action(
"set_safety_checks",
TR.tr("safety_checks__title"),
description=TR.tr("safety_checks__enforce_strict"),
TR.safety_checks__title,
description=TR.safety_checks__enforce_strict,
br_code=BRT_PROTECT_CALL,
)
elif level in (SafetyCheckLevel.PromptAlways, SafetyCheckLevel.PromptTemporarily):
description = (
TR.tr("safety_checks__approve_unsafe_temporary")
TR.safety_checks__approve_unsafe_temporary
if level == SafetyCheckLevel.PromptTemporarily
else TR.tr("safety_checks__approve_unsafe_always")
else TR.safety_checks__approve_unsafe_always
)
await confirm_action(
"set_safety_checks",
TR.tr("safety_checks__title_safety_override"),
TR.tr("words__are_you_sure"),
TR.safety_checks__title_safety_override,
TR.words__are_you_sure,
description,
hold=True,
verb=TR.tr("buttons__hold_to_confirm"),
verb=TR.buttons__hold_to_confirm,
reverse=True,
br_code=BRT_PROTECT_CALL,
)
@ -265,9 +265,9 @@ async def _require_confirm_experimental_features(enable: bool) -> None:
if enable:
await confirm_action(
"set_experimental_features",
TR.tr("experimental_mode__title"),
TR.tr("experimental_mode__only_for_dev"),
TR.tr("experimental_mode__enable"),
TR.experimental_mode__title,
TR.experimental_mode__only_for_dev,
TR.experimental_mode__enable,
reverse=True,
br_code=BRT_PROTECT_CALL,
)
@ -277,7 +277,7 @@ async def _require_confirm_hide_passphrase_from_host(enable: bool) -> None:
if enable:
await confirm_action(
"set_hide_passphrase_from_host",
TR.tr("passphrase__title_hide"),
description=TR.tr("passphrase__hide"),
TR.passphrase__title_hide,
description=TR.passphrase__hide,
br_code=BRT_PROTECT_CALL,
)

@ -5,7 +5,7 @@ if TYPE_CHECKING:
async def authenticate_device(msg: AuthenticateDevice) -> AuthenticityProof:
import trezortranslate as TR
from trezortranslate import TR
from trezor import utils, wire
from trezor.crypto import optiga
from trezor.crypto.der import read_length
@ -23,11 +23,9 @@ async def authenticate_device(msg: AuthenticateDevice) -> AuthenticityProof:
await confirm_action(
"authenticate_device",
TR.tr("authenticate__header"),
description=TR.tr("authenticate__confirm_template").format(
utils.MODEL_FULL_NAME
),
verb=TR.tr("buttons__allow"),
TR.authenticate__header,
description=TR.authenticate__confirm_template.format(utils.MODEL_FULL_NAME),
verb=TR.buttons__allow,
)
header = b"AuthenticateDevice:"
@ -37,7 +35,7 @@ async def authenticate_device(msg: AuthenticateDevice) -> AuthenticityProof:
write_compact_size(h, len(msg.challenge))
h.extend(msg.challenge)
spinner = progress("", description=TR.tr("progress__authenticity_check"))
spinner = progress("", description=TR.progress__authenticity_check)
spinner.report(0)
try:

@ -63,19 +63,19 @@ async def send_request_chunk(data_left: int) -> TranslationDataAck:
async def _require_confirm_change_language(language: str) -> None:
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_action
# TODO: might also show the length of the data, so user can check it with client?
# Empty language means default language (english)
if language:
description = TR.tr("language__change_template").format(language)
description = TR.language__change_template.format(language)
else:
description = TR.tr("language__set_default")
description = TR.language__set_default
await confirm_action(
"set_language",
TR.tr("language__title_change"),
TR.language__title_change,
description=description,
br_code=ButtonRequestType.ProtectCall,
)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor import config, wire
if TYPE_CHECKING:
@ -28,7 +28,7 @@ async def change_pin(msg: ChangePin) -> Success:
await _require_confirm_change_pin(msg)
# get old pin
curpin, salt = await request_pin_and_sd_salt(TR.tr("pin__enter"))
curpin, salt = await request_pin_and_sd_salt(TR.pin__enter)
# if changing pin, pre-check the entered pin before getting new pin
if curpin and not msg.remove:
@ -50,13 +50,13 @@ async def change_pin(msg: ChangePin) -> Success:
if newpin:
if curpin:
msg_screen = TR.tr("pin__changed")
msg_screen = TR.pin__changed
msg_wire = "PIN changed"
else:
msg_screen = TR.tr("pin__enabled")
msg_screen = TR.pin__enabled
msg_wire = "PIN enabled"
else:
msg_screen = TR.tr("pin__disabled")
msg_screen = TR.pin__disabled
msg_wire = "PIN removed"
await show_success("success_pin", msg_screen)
@ -71,25 +71,25 @@ def _require_confirm_change_pin(msg: ChangePin) -> Awaitable[None]:
if msg.remove and has_pin: # removing pin
return confirm_action(
"disable_pin",
TR.tr("pin__title_settings"),
description=TR.tr("pin__turn_off"),
verb=TR.tr("buttons__turn_off"),
TR.pin__title_settings,
description=TR.pin__turn_off,
verb=TR.buttons__turn_off,
)
if not msg.remove and has_pin: # changing pin
return confirm_action(
"change_pin",
TR.tr("pin__title_settings"),
description=TR.tr("pin__change"),
verb=TR.tr("buttons__change"),
TR.pin__title_settings,
description=TR.pin__change,
verb=TR.buttons__change,
)
if not msg.remove and not has_pin: # setting new pin
return confirm_set_new_pin(
"set_pin",
TR.tr("pin__title_settings"),
TR.tr("pin__turn_on"),
TR.tr("pin__info"),
TR.pin__title_settings,
TR.pin__turn_on,
TR.pin__info,
)
# removing non-existing PIN

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
if TYPE_CHECKING:
from typing import Awaitable
@ -25,7 +25,7 @@ async def change_wipe_code(msg: ChangeWipeCode) -> Success:
await _require_confirm_action(msg, has_wipe_code)
# Get the unlocking PIN.
pin, salt = await request_pin_and_sd_salt(TR.tr("pin__enter"))
pin, salt = await request_pin_and_sd_salt(TR.pin__enter)
if not msg.remove:
# Pre-check the entered PIN.
@ -43,13 +43,13 @@ async def change_wipe_code(msg: ChangeWipeCode) -> Success:
if wipe_code:
if has_wipe_code:
msg_screen = TR.tr("wipe_code__changed")
msg_screen = TR.wipe_code__changed
msg_wire = "Wipe code changed"
else:
msg_screen = TR.tr("wipe_code__enabled")
msg_screen = TR.wipe_code__enabled
msg_wire = "Wipe code set"
else:
msg_screen = TR.tr("wipe_code__disabled")
msg_screen = TR.wipe_code__disabled
msg_wire = "Wipe code removed"
await show_success("success_wipe_code", msg_screen)
@ -65,25 +65,25 @@ def _require_confirm_action(
if msg.remove and has_wipe_code:
return confirm_action(
"disable_wipe_code",
TR.tr("wipe_code__title_settings"),
description=TR.tr("wipe_code__turn_off"),
verb=TR.tr("buttons__turn_off"),
TR.wipe_code__title_settings,
description=TR.wipe_code__turn_off,
verb=TR.buttons__turn_off,
)
if not msg.remove and has_wipe_code:
return confirm_action(
"change_wipe_code",
TR.tr("wipe_code__title_settings"),
description=TR.tr("wipe_code__change"),
verb=TR.tr("buttons__change"),
TR.wipe_code__title_settings,
description=TR.wipe_code__change,
verb=TR.buttons__change,
)
if not msg.remove and not has_wipe_code:
return confirm_set_new_pin(
"set_wipe_code",
TR.tr("wipe_code__title_settings"),
TR.tr("wipe_code__turn_on"),
TR.tr("wipe_code__info"),
TR.wipe_code__title_settings,
TR.wipe_code__turn_on,
TR.wipe_code__info,
)
# Removing non-existing wipe code.
@ -100,12 +100,12 @@ async def _request_wipe_code_confirm(pin: str) -> str:
from apps.common.request_pin import request_pin
while True:
code1 = await request_pin(TR.tr("wipe_code__enter_new"))
code1 = await request_pin(TR.wipe_code__enter_new)
if code1 == pin:
await wipe_code_same_as_pin_popup()
continue
await confirm_reenter_pin(is_wipe_code=True)
code2 = await request_pin(TR.tr("wipe_code__reenter"))
code2 = await request_pin(TR.wipe_code__reenter)
if code1 == code2:
return code1
await pin_mismatch_popup(is_wipe_code=True)

@ -6,7 +6,7 @@ if TYPE_CHECKING:
async def get_next_u2f_counter(msg: GetNextU2FCounter) -> NextU2FCounter:
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.messages import NextU2FCounter
from trezor.ui.layouts import confirm_action
@ -17,8 +17,8 @@ async def get_next_u2f_counter(msg: GetNextU2FCounter) -> NextU2FCounter:
await confirm_action(
"get_u2f_counter",
TR.tr("u2f__title_get"),
description=TR.tr("u2f__get"),
TR.u2f__title_get,
description=TR.u2f__get,
br_code=ButtonRequestType.ProtectCall,
)

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def reboot_to_bootloader(msg: RebootToBootloader) -> NoReturn:
import trezortranslate as TR
from trezortranslate import TR
from trezor import io, loop, utils
from trezor.messages import Success
from trezor.ui.layouts import confirm_action
@ -15,9 +15,9 @@ async def reboot_to_bootloader(msg: RebootToBootloader) -> NoReturn:
await confirm_action(
"reboot",
TR.tr("reboot_to_bootloader__title"),
TR.tr("reboot_to_bootloader__restart"),
verb=TR.tr("buttons__restart"),
TR.reboot_to_bootloader__title,
TR.reboot_to_bootloader__restart,
verb=TR.buttons__restart,
)
ctx = get_context()
await ctx.write(Success(message="Rebooting"))

@ -19,7 +19,7 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
import storage
import storage.device as storage_device
import storage.recovery as storage_recovery
import trezortranslate as TR
from trezortranslate import TR
from trezor import config, wire, workflow
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_action, confirm_reset_device
@ -58,14 +58,14 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
# --------------------------------------------------------
# _continue_dialog
if not dry_run:
await confirm_reset_device(TR.tr("recovery__title_recover"), recovery=True)
await confirm_reset_device(TR.recovery__title_recover, recovery=True)
else:
await confirm_action(
"confirm_seedcheck",
TR.tr("recovery__title_dry_run"),
description=TR.tr("recovery__check_dry_run"),
TR.recovery__title_dry_run,
description=TR.recovery__check_dry_run,
br_code=ButtonRequestType.ProtectCall,
verb=TR.tr("buttons__check"),
verb=TR.buttons__check,
)
# END _continue_dialog
# --------------------------------------------------------
@ -76,7 +76,7 @@ async def recovery_device(msg: RecoveryDevice) -> Success:
# for dry run pin needs to be entered
if dry_run:
curpin, salt = await request_pin_and_sd_salt(TR.tr("pin__enter"))
curpin, salt = await request_pin_and_sd_salt(TR.pin__enter)
if not config.check_pin(curpin, salt):
await error_pin_invalid()

@ -3,7 +3,7 @@ from typing import TYPE_CHECKING
import storage.device as storage_device
import storage.recovery as storage_recovery
import storage.recovery_shares as storage_recovery_shares
import trezortranslate as TR
from trezortranslate import TR
from trezor import wire
from trezor.messages import Success
@ -69,7 +69,7 @@ async def _continue_recovery_process() -> Success:
# For TT, just continuing straight to word count keyboard
if utils.INTERNAL_MODEL == "T2B1":
await layout.homescreen_dialog(
TR.tr("buttons__continue"), TR.tr("recovery__num_of_words")
TR.buttons__continue, TR.recovery__num_of_words
)
# ask for the number of words
word_count = await layout.request_word_count(dry_run)
@ -159,7 +159,7 @@ async def _finish_recovery(secret: bytes, backup_type: BackupType) -> Success:
storage_recovery.end_progress()
await show_success("success_recovery", TR.tr("recovery__wallet_recovered"))
await show_success("success_recovery", TR.recovery__wallet_recovered)
return Success(message="Device recovered")
@ -190,16 +190,16 @@ async def _request_share_first_screen(word_count: int) -> None:
await _request_share_next_screen()
else:
await layout.homescreen_dialog(
TR.tr("buttons__enter_share"),
TR.tr("recovery__enter_any_share"),
TR.tr("recovery__word_count_template").format(word_count),
TR.buttons__enter_share,
TR.recovery__enter_any_share,
TR.recovery__word_count_template.format(word_count),
show_info=True,
)
else: # BIP-39
await layout.homescreen_dialog(
TR.tr("buttons__continue"),
TR.tr("recovery__enter_backup"),
TR.tr("recovery__word_count_template").format(word_count),
TR.buttons__continue,
TR.recovery__enter_backup,
TR.recovery__word_count_template.format(word_count),
show_info=True,
)
@ -215,8 +215,8 @@ async def _request_share_next_screen() -> None:
if group_count > 1:
await layout.homescreen_dialog(
TR.tr("buttons__enter"),
TR.tr("recovery__more_shares_needed"),
TR.buttons__enter,
TR.recovery__more_shares_needed,
info_func=_show_remaining_groups_and_shares,
)
else:
@ -224,14 +224,14 @@ async def _request_share_next_screen() -> None:
already_entered_shares = len(storage_recovery_shares.fetch_group(0))
overall_needed = still_needed_shares + already_entered_shares
# TODO: consider kwargs in format here
entered = TR.tr("recovery__x_of_y_entered_template").format(
entered = TR.recovery__x_of_y_entered_template.format(
already_entered_shares, overall_needed
)
# TODO: support these plurals
needed = strings.format_plural(
"{count} more {plural} needed.", still_needed_shares, "share"
)
await layout.homescreen_dialog(TR.tr("buttons__enter_share"), entered, needed)
await layout.homescreen_dialog(TR.buttons__enter_share, entered, needed)
async def _show_remaining_groups_and_shares() -> None:

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_action
from trezor.ui.layouts.recovery import ( # noqa: F401
@ -22,19 +22,19 @@ async def _confirm_abort(dry_run: bool = False) -> None:
if dry_run:
await confirm_action(
"abort_recovery",
TR.tr("recovery__title_cancel_dry_run"),
TR.tr("recovery__cancel_dry_run"),
description=TR.tr("recovery__wanna_cancel_dry_run"),
verb=TR.tr("buttons__cancel"),
TR.recovery__title_cancel_dry_run,
TR.recovery__cancel_dry_run,
description=TR.recovery__wanna_cancel_dry_run,
verb=TR.buttons__cancel,
br_code=ButtonRequestType.ProtectCall,
)
else:
await confirm_action(
"abort_recovery",
TR.tr("recovery__title_cancel_recovery"),
TR.tr("recovery__progress_will_be_lost"),
TR.tr("recovery__wanna_cancel_recovery"),
verb=TR.tr("buttons__cancel"),
TR.recovery__title_cancel_recovery,
TR.recovery__progress_will_be_lost,
TR.recovery__wanna_cancel_recovery,
verb=TR.buttons__cancel,
reverse=True,
br_code=ButtonRequestType.ProtectCall,
)
@ -63,23 +63,23 @@ async def request_mnemonic(
# show_share_already_added
await show_recovery_warning(
"warning_known_share",
TR.tr("recovery__share_already_entered"),
TR.tr("recovery__enter_different_share"),
TR.recovery__share_already_entered,
TR.recovery__enter_different_share,
)
return None
except word_validity.IdentifierMismatch:
# show_identifier_mismatch
await show_recovery_warning(
"warning_mismatched_share",
TR.tr("recovery__share_from_another_shamir"),
TR.recovery__share_from_another_shamir,
)
return None
except word_validity.ThresholdReached:
# show_group_threshold_reached
await show_recovery_warning(
"warning_group_threshold",
TR.tr("recovery__group_threshold_reached"),
TR.tr("recovery__enter_share_from_diff_group"),
TR.recovery__group_threshold_reached,
TR.recovery__enter_share_from_diff_group,
)
return None
@ -91,19 +91,17 @@ async def show_dry_run_result(result: bool, is_slip39: bool) -> None:
if result:
if is_slip39:
text = TR.tr("recovery__dry_run_slip39_valid_match")
text = TR.recovery__dry_run_slip39_valid_match
else:
text = TR.tr("recovery__dry_run_bip39_valid_match")
await show_success(
"success_dry_recovery", text, button=TR.tr("buttons__continue")
)
text = TR.recovery__dry_run_bip39_valid_match
await show_success("success_dry_recovery", text, button=TR.buttons__continue)
else:
if is_slip39:
text = TR.tr("recovery__dry_run_slip39_valid_mismatch")
text = TR.recovery__dry_run_slip39_valid_mismatch
else:
text = TR.tr("recovery__dry_run_bip39_valid_mismatch")
text = TR.recovery__dry_run_bip39_valid_mismatch
await show_recovery_warning(
"warning_dry_recovery", "", text, button=TR.tr("buttons__continue")
"warning_dry_recovery", "", text, button=TR.buttons__continue
)
@ -111,14 +109,14 @@ async def show_invalid_mnemonic(word_count: int) -> None:
if backup_types.is_slip39_word_count(word_count):
await show_recovery_warning(
"warning_invalid_share",
TR.tr("recovery__invalid_share_entered"),
TR.tr("words__please_try_again"),
TR.recovery__invalid_share_entered,
TR.words__please_try_again,
)
else:
await show_recovery_warning(
"warning_invalid_seed",
TR.tr("recovery__invalid_seed_entered"),
TR.tr("words__please_try_again"),
TR.recovery__invalid_seed_entered,
TR.words__please_try_again,
)

@ -22,7 +22,7 @@ _DEFAULT_BACKUP_TYPE = BAK_T_BIP39
async def reset_device(msg: ResetDevice) -> Success:
import trezortranslate as TR
from trezortranslate import TR
from trezor import config
from trezor.crypto import bip39, random
from trezor.messages import EntropyAck, EntropyRequest, Success
@ -39,13 +39,13 @@ async def reset_device(msg: ResetDevice) -> Success:
# make sure user knows they're setting up a new wallet
if backup_type in (BAK_T_SLIP39_BASIC, BAK_T_SLIP39_ADVANCED):
title = TR.tr("reset__title_create_wallet_shamir")
title = TR.reset__title_create_wallet_shamir
else:
title = TR.tr("reset__title_create_wallet")
title = TR.reset__title_create_wallet
await confirm_reset_device(title)
# Rendering empty loader so users do not feel a freezing screen
render_empty_loader(TR.tr("progress__processing"), "")
render_empty_loader(TR.progress__processing, "")
# wipe storage to make sure the device is in a clear state
storage.reset()

@ -1,7 +1,7 @@
from micropython import const
from typing import Sequence
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import show_success
from trezor.ui.layouts.reset import ( # noqa: F401
@ -21,7 +21,7 @@ async def show_internal_entropy(entropy: bytes) -> None:
await confirm_blob(
"entropy",
TR.tr("entropy__title"),
TR.entropy__title,
entropy,
br_code=ButtonRequestType.ResetDevice,
)
@ -111,29 +111,29 @@ async def _show_confirmation_success(
group_index: int | None = None,
) -> None:
if share_index is None or num_of_shares is None: # it is a BIP39 backup
subheader = TR.tr("reset__finished_verifying_seed")
subheader = TR.reset__finished_verifying_seed
text = ""
elif share_index == num_of_shares - 1:
if group_index is None:
subheader = TR.tr("reset__finished_verifying_shares")
subheader = TR.reset__finished_verifying_shares
else:
subheader = TR.tr("reset__finished_verifying_group_template").format(
subheader = TR.reset__finished_verifying_group_template.format(
group_index + 1
)
text = ""
else:
if group_index is None:
subheader = TR.tr("reset__share_checked_successfully_template").format(
subheader = TR.reset__share_checked_successfully_template.format(
share_index + 1
)
text = TR.tr("reset__continue_with_share_template").format(share_index + 2)
text = TR.reset__continue_with_share_template.format(share_index + 2)
else:
subheader = TR.tr(
"reset__group_share_checked_successfully_template"
).format(group_index + 1, share_index + 1)
text = TR.tr("reset__continue_with_next_share")
subheader = TR.reset__group_share_checked_successfully_template.format(
group_index + 1, share_index + 1
)
text = TR.reset__continue_with_next_share
return await show_success("success_recovery", text, subheader)
@ -143,9 +143,9 @@ async def _show_confirmation_failure() -> None:
await show_reset_warning(
"warning_backup_check",
TR.tr("words__please_check_again"),
TR.tr("reset__wrong_word_selected"),
TR.tr("buttons__check_again"),
TR.words__please_check_again,
TR.reset__wrong_word_selected,
TR.buttons__check_again,
ButtonRequestType.ResetDevice,
)

@ -2,7 +2,7 @@ from typing import TYPE_CHECKING
import storage.device as storage_device
import storage.sd_salt as storage_sd_salt
import trezortranslate as TR
from trezortranslate import TR
from trezor import config
from trezor.enums import SdProtectOperationType
from trezor.messages import Success
@ -68,7 +68,7 @@ async def _sd_protect_enable(msg: SdProtect) -> Success:
# Get the current PIN.
if config.has_pin():
pin = await request_pin(TR.tr("pin__enter"), config.get_pin_rem())
pin = await request_pin(TR.pin__enter, config.get_pin_rem())
else:
pin = ""
@ -89,7 +89,7 @@ async def _sd_protect_enable(msg: SdProtect) -> Success:
storage_device.set_sd_salt_auth_key(salt_auth_key)
await show_success("success_sd", TR.tr("sd_card__enabled"))
await show_success("success_sd", TR.sd_card__enabled)
return Success(message="SD card protection enabled")
@ -104,7 +104,7 @@ async def _sd_protect_disable(msg: SdProtect) -> Success:
await require_confirm_sd_protect(msg)
# Get the current PIN and salt from the SD card.
pin, salt = await request_pin_and_sd_salt(TR.tr("pin__enter"))
pin, salt = await request_pin_and_sd_salt(TR.pin__enter)
# Check PIN and remove salt.
if not config.change_pin(pin, pin, salt, None):
@ -121,7 +121,7 @@ async def _sd_protect_disable(msg: SdProtect) -> Success:
# because overall SD-protection was successfully disabled.
pass
await show_success("success_sd", TR.tr("sd_card__disabled"))
await show_success("success_sd", TR.sd_card__disabled)
return Success(message="SD card protection disabled")
@ -136,7 +136,7 @@ async def _sd_protect_refresh(msg: SdProtect) -> Success:
await ensure_sdcard()
# Get the current PIN and salt from the SD card.
pin, old_salt = await request_pin_and_sd_salt(TR.tr("pin__enter"))
pin, old_salt = await request_pin_and_sd_salt(TR.pin__enter)
# Check PIN and change salt.
new_salt, new_auth_key, new_salt_tag = _make_salt()
@ -156,7 +156,7 @@ async def _sd_protect_refresh(msg: SdProtect) -> Success:
# SD-protection was successfully refreshed.
pass
await show_success("success_sd", TR.tr("sd_card__refreshed"))
await show_success("success_sd", TR.sd_card__refreshed)
return Success(message="SD card protection refreshed")
@ -164,12 +164,12 @@ def require_confirm_sd_protect(msg: SdProtect) -> Awaitable[None]:
from trezor.ui.layouts import confirm_action
if msg.operation == SdProtectOperationType.ENABLE:
text = TR.tr("sd_card__enable")
text = TR.sd_card__enable
elif msg.operation == SdProtectOperationType.DISABLE:
text = TR.tr("sd_card__disable")
text = TR.sd_card__disable
elif msg.operation == SdProtectOperationType.REFRESH:
text = TR.tr("sd_card__refresh")
text = TR.sd_card__refresh
else:
raise ProcessError("Unknown operation")
return confirm_action("set_sd", TR.tr("sd_card__title"), description=text)
return confirm_action("set_sd", TR.sd_card__title, description=text)

@ -6,7 +6,7 @@ if TYPE_CHECKING:
async def set_u2f_counter(msg: SetU2FCounter) -> Success:
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor import wire
from trezor.enums import ButtonRequestType
from trezor.messages import Success
@ -19,10 +19,10 @@ async def set_u2f_counter(msg: SetU2FCounter) -> Success:
await confirm_action(
"set_u2f_counter",
TR.tr("u2f__title_set"),
description=TR.tr("u2f__set_template"),
TR.u2f__title_set,
description=TR.u2f__set_template,
description_param=str(msg.u2f_counter),
verb=TR.tr("buttons__set"),
verb=TR.buttons__set,
br_code=ButtonRequestType.ProtectCall,
)

@ -6,7 +6,7 @@ if TYPE_CHECKING:
async def wipe_device(msg: WipeDevice) -> Success:
import storage
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.messages import Success
from trezor.ui.layouts import confirm_action
@ -15,11 +15,11 @@ async def wipe_device(msg: WipeDevice) -> Success:
await confirm_action(
"confirm_wipe",
TR.tr("wipe__title"),
TR.tr("wipe__info"),
TR.tr("wipe__want_to_wipe"),
TR.wipe__title,
TR.wipe__info,
TR.wipe__want_to_wipe,
reverse=True,
verb=TR.tr("buttons__hold_to_confirm"),
verb=TR.buttons__hold_to_confirm,
hold=True,
hold_danger=True,
br_code=ButtonRequestType.WipeDevice,

@ -8,7 +8,7 @@ if TYPE_CHECKING:
async def cipher_key_value(msg: CipherKeyValue) -> CipheredKeyValue:
import trezortranslate as TR
from trezortranslate import TR
from trezor.crypto import aes, hmac
from trezor.messages import CipheredKeyValue
from trezor.ui.layouts import confirm_action
@ -27,14 +27,14 @@ async def cipher_key_value(msg: CipherKeyValue) -> CipheredKeyValue:
if (encrypt and msg.ask_on_encrypt) or (decrypt and msg.ask_on_decrypt):
# Special case for Trezor Suite, which asks for setting up labels
if msg.key == "Enable labeling?":
title = TR.tr("misc__title_suite_labeling")
verb = TR.tr("buttons__enable")
title = TR.misc__title_suite_labeling
verb = TR.buttons__enable
else:
if encrypt:
title = TR.tr("misc__encrypt_value")
title = TR.misc__encrypt_value
else:
title = TR.tr("misc__decrypt_value")
verb = TR.tr("buttons__confirm")
title = TR.misc__decrypt_value
verb = TR.buttons__confirm
await confirm_action("cipher_key_value", title, description=msg.key, verb=verb)

@ -5,7 +5,7 @@ if TYPE_CHECKING:
async def get_entropy(msg: GetEntropy) -> Entropy:
import trezortranslate as TR
from trezortranslate import TR
from trezor.crypto import random
from trezor.enums import ButtonRequestType
from trezor.messages import Entropy
@ -13,9 +13,9 @@ async def get_entropy(msg: GetEntropy) -> Entropy:
await confirm_action(
"get_entropy",
TR.tr("entropy__title_confirm"),
TR.tr("entropy__send"),
TR.tr("words__know_what_your_doing"),
TR.entropy__title_confirm,
TR.entropy__send,
TR.words__know_what_your_doing,
br_code=ButtonRequestType.ProtectCall,
)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_action, confirm_metadata # noqa: F401
from trezor.ui.layouts.progress import ( # noqa: F401
@ -29,25 +29,25 @@ class MoneroTransactionProgress:
def step(self, state: State, step: int, sub_step: int = 0) -> None:
if step == 0 or self.inner is None:
self.inner = monero_transaction_progress_inner()
info = TR.tr("monero__signing")
info = TR.monero__signing
elif step == state.STEP_INP:
info = f"{TR.tr('monero__processing_inputs')}\n{sub_step + 1}/{state.input_count}"
info = f"{TR.monero__processing_inputs}\n{sub_step + 1}/{state.input_count}"
elif step == state.STEP_VINI:
info = (
f"{TR.tr('monero__hashing_inputs')}n{sub_step + 1}/{state.input_count}"
f"{TR.monero__hashing_inputs}n{sub_step + 1}/{state.input_count}"
)
elif step == state.STEP_ALL_IN:
info = TR.tr("monero__processing")
info = TR.monero__processing
elif step == state.STEP_OUT:
info = f"{TR.tr('monero__processing_outputs')}\n{sub_step + 1}/{state.output_count}"
info = f"{TR.monero__processing_outputs}\n{sub_step + 1}/{state.output_count}"
elif step == state.STEP_ALL_OUT:
info = TR.tr("monero__postprocessing")
info = TR.monero__postprocessing
elif step == state.STEP_SIGN:
info = (
f"{TR.tr('monero__signing_inputs')}\n{sub_step + 1}/{state.input_count}"
f"{TR.monero__signing_inputs}\n{sub_step + 1}/{state.input_count}"
)
else:
info = TR.tr("monero__processing")
info = TR.monero__processing
state.progress_cur += 1
@ -64,8 +64,8 @@ def _format_amount(value: int) -> str:
async def require_confirm_watchkey() -> None:
await confirm_action(
"get_watchkey",
TR.tr("monero__confirm_export"),
description=TR.tr("monero__wanna_export_watchkey"),
TR.monero__confirm_export,
description=TR.monero__wanna_export_watchkey,
br_code=BRT_SignTx,
)
@ -73,8 +73,8 @@ async def require_confirm_watchkey() -> None:
async def require_confirm_keyimage_sync() -> None:
await confirm_action(
"key_image_sync",
TR.tr("monero__confirm_ki_sync"),
description=TR.tr("monero__wanna_sync_key_images"),
TR.monero__confirm_ki_sync,
description=TR.monero__wanna_sync_key_images,
br_code=BRT_SignTx,
)
@ -82,21 +82,19 @@ async def require_confirm_keyimage_sync() -> None:
async def require_confirm_live_refresh() -> None:
await confirm_action(
"live_refresh",
TR.tr("monero__confirm_refresh"),
description=TR.tr("monero__wanna_start_refresh"),
TR.monero__confirm_refresh,
description=TR.monero__wanna_start_refresh,
br_code=BRT_SignTx,
)
async def require_confirm_tx_key(export_key: bool = False) -> None:
description = (
TR.tr("monero__wanna_export_tx_key")
if export_key
else TR.tr("monero__wanna_export_tx_der")
TR.monero__wanna_export_tx_key if export_key else TR.monero__wanna_export_tx_der
)
await confirm_action(
"export_tx_key",
TR.tr("monero__confirm_export"),
TR.monero__confirm_export,
description=description,
br_code=BRT_SignTx,
)
@ -178,7 +176,7 @@ async def _require_confirm_payment_id(payment_id: bytes) -> None:
await confirm_blob(
"confirm_payment_id",
TR.tr("monero__payment_id"),
TR.monero__payment_id,
payment_id,
br_code=BRT_SignTx,
)
@ -187,7 +185,7 @@ async def _require_confirm_payment_id(payment_id: bytes) -> None:
async def _require_confirm_fee(fee: int) -> None:
await confirm_metadata(
"confirm_final",
TR.tr("monero__confirm_fee"),
TR.monero__confirm_fee,
"{}",
_format_amount(fee),
hold=True,
@ -197,8 +195,8 @@ async def _require_confirm_fee(fee: int) -> None:
async def _require_confirm_unlock_time(unlock_time: int) -> None:
await confirm_metadata(
"confirm_locktime",
TR.tr("monero__confirm_unlock_time"),
TR.tr("monero__unlock_time_set_template"),
TR.monero__confirm_unlock_time,
TR.monero__unlock_time_set_template,
str(unlock_time),
BRT_SignTx,
)

@ -1,4 +1,4 @@
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.strings import format_amount
from trezor.ui.layouts import confirm_metadata
@ -9,7 +9,7 @@ from .helpers import NEM_MAX_DIVISIBILITY
async def require_confirm_text(action: str) -> None:
await confirm_metadata(
"confirm_nem",
TR.tr("nem__confirm_action"),
TR.nem__confirm_action,
action,
br_code=ButtonRequestType.ConfirmOutput,
)
@ -18,7 +18,7 @@ async def require_confirm_text(action: str) -> None:
async def require_confirm_fee(action: str, fee: int) -> None:
await confirm_metadata(
"confirm_fee",
TR.tr("nem__confirm_fee"),
TR.nem__confirm_fee,
action + "\n{}",
f"{format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM",
ButtonRequestType.ConfirmOutput,
@ -39,8 +39,8 @@ async def require_confirm_final(fee: int) -> None:
# we use SignTx, not ConfirmOutput, for compatibility with T1
await confirm_metadata(
"confirm_final",
TR.tr("nem__final_confirm"),
TR.tr("nem__sign_tx_fee_template"),
TR.nem__final_confirm,
TR.nem__sign_tx_fee_template,
f"{format_amount(fee, NEM_MAX_DIVISIBILITY)} XEM",
hold=True,
)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from ..layout import require_confirm_content, require_confirm_final
@ -19,12 +19,12 @@ async def ask_mosaic_creation(
from ..layout import require_confirm_fee
creation_message = [
(TR.tr("nem__create_mosaic"), creation.definition.mosaic),
(TR.tr("nem__under_namespace"), creation.definition.namespace),
(TR.nem__create_mosaic, creation.definition.mosaic),
(TR.nem__under_namespace, creation.definition.namespace),
]
await require_confirm_content(TR.tr("nem__create_mosaic"), creation_message)
await require_confirm_content(TR.nem__create_mosaic, creation_message)
await _require_confirm_properties(creation.definition)
await require_confirm_fee(TR.tr("nem__confirm_creation_fee"), creation.fee)
await require_confirm_fee(TR.nem__confirm_creation_fee, creation.fee)
await require_confirm_final(common.fee)
@ -37,18 +37,18 @@ async def ask_supply_change(
from ..layout import require_confirm_text
supply_message = [
(TR.tr("nem__modify_supply_for"), change.mosaic),
(TR.tr("nem__under_namespace"), change.namespace),
(TR.nem__modify_supply_for, change.mosaic),
(TR.nem__under_namespace, change.namespace),
]
await require_confirm_content(TR.tr("nem__supply_change"), supply_message)
await require_confirm_content(TR.nem__supply_change, supply_message)
if change.type == NEMSupplyChangeType.SupplyChange_Decrease:
action = TR.tr("nem__decrease")
action = TR.nem__decrease
elif change.type == NEMSupplyChangeType.SupplyChange_Increase:
action = TR.tr("nem__increase")
action = TR.nem__increase
else:
raise ValueError("Invalid supply change type")
await require_confirm_text(
TR.tr("nem__supply_units_template").format(action, change.delta)
TR.nem__supply_units_template.format(action, change.delta)
)
await require_confirm_final(common.fee)
@ -63,20 +63,18 @@ async def _require_confirm_properties(definition: NEMMosaicDefinition) -> None:
# description
if definition.description:
append((TR.tr("nem__description"), definition.description))
append((TR.nem__description, definition.description))
# transferable
transferable = TR.tr("nem__yes") if definition.transferable else TR.tr("nem__no")
append((TR.tr("nem__transferable"), transferable))
transferable = TR.nem__yes if definition.transferable else TR.nem__no
append((TR.nem__transferable, transferable))
# mutable_supply
imm = (
TR.tr("nem__mutable") if definition.mutable_supply else TR.tr("nem__immutable")
)
imm = TR.nem__mutable if definition.mutable_supply else TR.nem__immutable
if definition.supply:
append((TR.tr("nem__initial_supply"), str(definition.supply) + "\n" + imm))
append((TR.nem__initial_supply, str(definition.supply) + "\n" + imm))
else:
append((TR.tr("nem__initial_supply"), imm))
append((TR.nem__initial_supply, imm))
# levy
if definition.levy:
@ -85,23 +83,23 @@ async def _require_confirm_properties(definition: NEMMosaicDefinition) -> None:
assert definition.levy_namespace is not None
assert definition.levy_mosaic is not None
append((TR.tr("nem__levy_recipient"), definition.levy_address))
append((TR.nem__levy_recipient, definition.levy_address))
append((TR.tr("nem__levy_fee"), str(definition.fee)))
append((TR.tr("nem__levy_divisibility"), str(definition.divisibility)))
append((TR.nem__levy_fee, str(definition.fee)))
append((TR.nem__levy_divisibility, str(definition.divisibility)))
append((TR.tr("nem__levy_namespace"), definition.levy_namespace))
append((TR.tr("nem__levy_mosaic"), definition.levy_mosaic))
append((TR.nem__levy_namespace, definition.levy_namespace))
append((TR.nem__levy_mosaic, definition.levy_mosaic))
levy_type = (
TR.tr("nem__absolute")
TR.nem__absolute
if definition.levy == NEMMosaicLevy.MosaicLevy_Absolute
else TR.tr("nem__percentile")
else TR.nem__percentile
)
append((TR.tr("nem__levy_type"), levy_type))
append((TR.nem__levy_type, levy_type))
await confirm_properties(
"confirm_properties",
TR.tr("nem__confirm_properties"),
TR.nem__confirm_properties,
properties,
)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.crypto import nem
if TYPE_CHECKING:
@ -18,10 +18,10 @@ async def ask_multisig(msg: NEMSignTx) -> None:
assert msg.multisig.signer is not None # sign_tx
address = nem.compute_address(msg.multisig.signer, msg.transaction.network)
if msg.cosigning:
await _require_confirm_address(TR.tr("nem__cosign_transaction_for"), address)
await _require_confirm_address(TR.nem__cosign_transaction_for, address)
else:
await _require_confirm_address(TR.tr("nem__initiate_transaction_for"), address)
await require_confirm_fee(TR.tr("nem__confirm_multisig_fee"), msg.transaction.fee)
await _require_confirm_address(TR.nem__initiate_transaction_for, address)
await require_confirm_fee(TR.nem__confirm_multisig_fee, msg.transaction.fee)
async def ask_aggregate_modification(
@ -34,21 +34,21 @@ async def ask_aggregate_modification(
from ..layout import require_confirm_final, require_confirm_text
if not multisig:
await require_confirm_text(TR.tr("nem__convert_account_to_multisig"))
await require_confirm_text(TR.nem__convert_account_to_multisig)
for m in mod.modifications:
if m.type == NEMModificationType.CosignatoryModification_Add:
action = TR.tr("nem__add")
action = TR.nem__add
else:
action = TR.tr("nem__remove")
action = TR.nem__remove
address = nem.compute_address(m.public_key, common.network)
await _require_confirm_address(action + TR.tr("nem__cosignatory"), address)
await _require_confirm_address(action + TR.nem__cosignatory, address)
if mod.relative_change:
if multisig:
action = TR.tr("nem__modify_the_number_of_cosignatories_by")
action = TR.nem__modify_the_number_of_cosignatories_by
else:
action = TR.tr("nem__set_minimum_cosignatories_to")
action = TR.nem__set_minimum_cosignatories_to
await require_confirm_text(action + str(mod.relative_change) + "?")
await require_confirm_final(common.fee)
@ -59,7 +59,7 @@ async def _require_confirm_address(action: str, address: str) -> None:
from trezor.ui.layouts import confirm_address
await confirm_address(
TR.tr("nem__confirm_address"),
TR.nem__confirm_address,
address,
action,
"confirm_multisig",

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def ask_provision_namespace(
common: NEMTransactionCommon, namespace: NEMProvisionNamespace
) -> None:
import trezortranslate as TR
from trezortranslate import TR
from ..layout import (
require_confirm_content,
@ -17,14 +17,14 @@ async def ask_provision_namespace(
if namespace.parent:
content = [
(TR.tr("nem__create_namespace"), namespace.namespace),
(TR.tr("nem__under_namespace"), namespace.parent),
(TR.nem__create_namespace, namespace.namespace),
(TR.nem__under_namespace, namespace.parent),
]
await require_confirm_content(TR.tr("nem__confirm_namespace"), content)
await require_confirm_content(TR.nem__confirm_namespace, content)
else:
content = [(TR.tr("nem__create_namespace"), namespace.namespace)]
await require_confirm_content(TR.tr("nem__confirm_namespace"), content)
content = [(TR.nem__create_namespace, namespace.namespace)]
await require_confirm_content(TR.nem__confirm_namespace, content)
await require_confirm_fee(TR.tr("nem__confirm_rental_fee"), namespace.fee)
await require_confirm_fee(TR.nem__confirm_rental_fee, namespace.fee)
await require_confirm_final(common.fee)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.strings import format_amount
@ -31,9 +31,9 @@ async def ask_transfer(
# require_confirm_payload
await confirm_text(
"confirm_payload",
TR.tr("nem__confirm_payload"),
TR.nem__confirm_payload,
bytes(transfer.payload).decode(),
TR.tr("nem__encrypted") if encrypted else TR.tr("nem__unencrypted"),
TR.nem__encrypted if encrypted else TR.nem__unencrypted,
ButtonRequestType.ConfirmOutput,
)
@ -68,14 +68,14 @@ async def _ask_transfer_mosaic(
if definition:
await confirm_properties(
"confirm_mosaic",
TR.tr("nem__confirm_mosaic"),
TR.nem__confirm_mosaic,
(
(
TR.tr("nem__confirm_transfer_of"),
TR.nem__confirm_transfer_of,
format_amount(mosaic_quantity, definition.divisibility)
+ definition.ticker,
),
(TR.tr("nem__of"), definition.name),
(TR.nem__of, definition.name),
),
)
levy = definition.levy # local_cache_attribute
@ -94,28 +94,28 @@ async def _ask_transfer_mosaic(
await confirm_properties(
"confirm_mosaic_levy",
TR.tr("nem__confirm_mosaic"),
((TR.tr("nem__levy_fee_of"), levy_msg),),
TR.nem__confirm_mosaic,
((TR.nem__levy_fee_of, levy_msg),),
)
else:
await confirm_action(
"confirm_mosaic_unknown",
TR.tr("nem__confirm_mosaic"),
TR.tr("nem__unknown_mosaic"),
TR.tr("nem__divisibility_and_levy_cannot_be_shown"),
TR.nem__confirm_mosaic,
TR.nem__unknown_mosaic,
TR.nem__divisibility_and_levy_cannot_be_shown,
br_code=ButtonRequestType.ConfirmOutput,
)
await confirm_properties(
"confirm_mosaic_transfer",
TR.tr("nem__confirm_mosaic"),
TR.nem__confirm_mosaic,
(
(
TR.tr("nem__confirm_transfer_of"),
TR.tr("nem__raw_units_template").format(mosaic_quantity),
TR.nem__confirm_transfer_of,
TR.nem__raw_units_template.format(mosaic_quantity),
),
(TR.tr("nem__of"), f"{mosaic.namespace}.{mosaic.mosaic}"),
(TR.nem__of, f"{mosaic.namespace}.{mosaic.mosaic}"),
),
)
@ -140,8 +140,8 @@ async def ask_importance_transfer(
from ..layout import require_confirm_text
if imp.mode == NEMImportanceTransferMode.ImportanceTransfer_Activate:
m = TR.tr("nem__activate")
m = TR.nem__activate
else:
m = TR.tr("nem__deactivate")
await require_confirm_text(m + TR.tr("nem__remote_harvesting"))
m = TR.nem__deactivate
await require_confirm_text(m + TR.nem__remote_harvesting)
await require_confirm_final(common.fee)

@ -13,12 +13,12 @@ async def require_confirm_total(total: int, fee: int) -> None:
async def require_confirm_destination_tag(tag: int) -> None:
import trezortranslate as TR
from trezortranslate import TR
await confirm_metadata(
"confirm_destination_tag",
TR.tr("ripple__confirm_tag"),
TR.tr("ripple__destination_tag_template"),
TR.ripple__confirm_tag,
TR.ripple__destination_tag_template,
str(tag),
ButtonRequestType.ConfirmOutput,
)

@ -1,7 +1,7 @@
from typing import TYPE_CHECKING
import trezor.ui.layouts as layouts
import trezortranslate as TR
from trezortranslate import TR
from trezor import strings
from trezor.enums import ButtonRequestType
@ -18,12 +18,12 @@ async def require_confirm_init(
accounts_match: bool,
) -> None:
description = (
TR.tr("stellar__initialize_signing_with") + TR.tr("stellar__your_account")
TR.stellar__initialize_signing_with + TR.stellar__your_account
if accounts_match
else ""
)
await layouts.confirm_address(
TR.tr("stellar__confirm_stellar"),
TR.stellar__confirm_stellar,
address,
description,
"confirm_init",
@ -33,15 +33,15 @@ async def require_confirm_init(
if network_passphrase == consts.NETWORK_PASSPHRASE_PUBLIC:
network = None
elif network_passphrase == consts.NETWORK_PASSPHRASE_TESTNET:
network = TR.tr("stellar__testnet_network")
network = TR.stellar__testnet_network
else:
network = TR.tr("stellar__private_network")
network = TR.stellar__private_network
if network:
await layouts.confirm_metadata(
"confirm_init_network",
TR.tr("stellar__confirm_network"),
TR.tr("stellar__on_network_template"),
TR.stellar__confirm_network,
TR.stellar__on_network_template,
network,
ButtonRequestType.ConfirmOutput,
)
@ -50,19 +50,19 @@ async def require_confirm_init(
async def require_confirm_timebounds(start: int, end: int) -> None:
await layouts.confirm_properties(
"confirm_timebounds",
TR.tr("stellar__confirm_timebounds"),
TR.stellar__confirm_timebounds,
(
(
TR.tr("stellar__valid_from"),
TR.stellar__valid_from,
strings.format_timestamp(start)
if start > 0
else TR.tr("stellar__no_restriction"),
else TR.stellar__no_restriction,
),
(
TR.tr("stellar__valid_to"),
TR.stellar__valid_to,
strings.format_timestamp(end)
if end > 0
else TR.tr("stellar__no_restriction"),
else TR.stellar__no_restriction,
),
),
)
@ -82,15 +82,15 @@ async def require_confirm_memo(memo_type: StellarMemoType, memo_text: str) -> No
else:
return await layouts.confirm_action(
"confirm_memo",
TR.tr("stellar__confirm_memo"),
TR.tr("stellar__no_memo_set"),
TR.tr("stellar__exchanges_require_memo"),
TR.stellar__confirm_memo,
TR.stellar__no_memo_set,
TR.stellar__exchanges_require_memo,
br_code=ButtonRequestType.ConfirmOutput,
)
await layouts.confirm_blob(
"confirm_memo",
TR.tr("stellar__confirm_memo"),
TR.stellar__confirm_memo,
memo_text,
description,
)
@ -99,12 +99,13 @@ async def require_confirm_memo(memo_type: StellarMemoType, memo_text: str) -> No
async def require_confirm_final(fee: int, num_operations: int) -> None:
# TODO: handle translation
op_str = strings.format_plural("{count} {plural}", num_operations, "operation")
text = TR.tr("stellar__sign_tx_count_template").format(op_str) + TR.tr(
"stellar__sign_tx_fee_template"
text = (
TR.stellar__sign_tx_count_template.format(op_str)
+ TR.stellar__sign_tx_fee_template
)
await layouts.confirm_metadata(
"confirm_final",
TR.tr("stellar__final_confirm"),
TR.stellar__final_confirm,
text,
format_amount(fee),
hold=True,

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
from trezor.ui.layouts import (
confirm_address,
confirm_amount,
@ -34,9 +34,9 @@ if TYPE_CHECKING:
async def confirm_source_account(source_account: str) -> None:
await confirm_address(
TR.tr("stellar__confirm_operation"),
TR.stellar__confirm_operation,
source_account,
TR.tr("stellar__source_account"),
TR.stellar__source_account,
"op_source_account",
)
@ -44,21 +44,19 @@ async def confirm_source_account(source_account: str) -> None:
async def confirm_allow_trust_op(op: StellarAllowTrustOp) -> None:
await confirm_properties(
"op_allow_trust",
TR.tr("stellar__allow_trust")
if op.is_authorized
else TR.tr("stellar__revoke_trust"),
TR.stellar__allow_trust if op.is_authorized else TR.stellar__revoke_trust,
(
(TR.tr("stellar__asset"), op.asset_code),
(TR.tr("stellar__trusted_account"), op.trusted_account),
(TR.stellar__asset, op.asset_code),
(TR.stellar__trusted_account, op.trusted_account),
),
)
async def confirm_account_merge_op(op: StellarAccountMergeOp) -> None:
await confirm_address(
TR.tr("stellar__account_merge"),
TR.stellar__account_merge,
op.destination_account,
TR.tr("stellar__all_will_be_sent_to"),
TR.stellar__all_will_be_sent_to,
"op_account_merge",
)
@ -66,19 +64,17 @@ async def confirm_account_merge_op(op: StellarAccountMergeOp) -> None:
async def confirm_bump_sequence_op(op: StellarBumpSequenceOp) -> None:
await confirm_metadata(
"op_bump",
TR.tr("stellar__bump_sequence"),
TR.tr("stellar__set_sequence_to_template"),
TR.stellar__bump_sequence,
TR.stellar__set_sequence_to_template,
str(op.bump_to),
)
async def confirm_change_trust_op(op: StellarChangeTrustOp) -> None:
await confirm_amount(
TR.tr("stellar__delete_trust")
if op.limit == 0
else TR.tr("stellar__add_trust"),
TR.stellar__delete_trust if op.limit == 0 else TR.stellar__add_trust,
format_amount(op.limit, op.asset),
TR.tr("stellar__limit"),
TR.stellar__limit,
"op_change_trust",
)
await confirm_asset_issuer(op.asset)
@ -87,10 +83,10 @@ async def confirm_change_trust_op(op: StellarChangeTrustOp) -> None:
async def confirm_create_account_op(op: StellarCreateAccountOp) -> None:
await confirm_properties(
"op_create_account",
TR.tr("stellar__create_account"),
TR.stellar__create_account,
(
(TR.tr("stellar__account"), op.new_account),
(TR.tr("stellar__initial_balance"), format_amount(op.starting_balance)),
(TR.stellar__account, op.new_account),
(TR.stellar__initial_balance, format_amount(op.starting_balance)),
),
)
@ -99,9 +95,9 @@ async def confirm_create_passive_sell_offer_op(
op: StellarCreatePassiveSellOfferOp,
) -> None:
text = (
TR.tr("stellar__delete_passive_offer")
TR.stellar__delete_passive_offer
if op.amount == 0
else TR.tr("stellar__new_passive_offer")
else TR.stellar__new_passive_offer
)
await _confirm_offer(text, op)
@ -118,9 +114,9 @@ async def _confirm_manage_offer_op_common(
op: StellarManageBuyOfferOp | StellarManageSellOfferOp,
) -> None:
if op.offer_id == 0:
text = TR.tr("stellar__new_offer")
text = TR.stellar__new_offer
else:
text = f"{TR.tr('stellar__delete') if op.amount == 0 else TR.tr('stellar__update')} #{op.offer_id}"
text = f"{TR.stellar__delete if op.amount == 0 else TR.stellar__update} #{op.offer_id}"
await _confirm_offer(text, op)
@ -138,10 +134,10 @@ async def _confirm_offer(
selling_asset = op.selling_asset # local_cache_attribute
if StellarManageBuyOfferOp.is_type_of(op):
buying = (TR.tr("stellar__buying"), format_amount(op.amount, buying_asset))
selling = (TR.tr("stellar__selling"), format_asset(selling_asset))
buying = (TR.stellar__buying, format_amount(op.amount, buying_asset))
selling = (TR.stellar__selling, format_asset(selling_asset))
price = (
TR.tr("stellar__price_per_template").format(format_asset(selling_asset)),
TR.stellar__price_per_template.format(format_asset(selling_asset)),
str(op.price_n / op.price_d),
)
await confirm_properties(
@ -150,10 +146,10 @@ async def _confirm_offer(
(buying, selling, price),
)
else:
selling = (TR.tr("stellar__selling"), format_amount(op.amount, selling_asset))
buying = (TR.tr("stellar__buying"), format_asset(buying_asset))
selling = (TR.stellar__selling, format_amount(op.amount, selling_asset))
buying = (TR.stellar__buying, format_asset(buying_asset))
price = (
TR.tr("stellar__price_per_template").format(format_asset(buying_asset)),
TR.stellar__price_per_template.format(format_asset(buying_asset)),
str(op.price_n / op.price_d),
)
await confirm_properties(
@ -173,14 +169,14 @@ async def confirm_manage_data_op(op: StellarManageDataOp) -> None:
digest = sha256(op.value).digest()
await confirm_properties(
"op_data",
TR.tr("stellar__set_data"),
((TR.tr("stellar__key"), op.key), (TR.tr("stellar__value_sha256"), digest)),
TR.stellar__set_data,
((TR.stellar__key, op.key), (TR.stellar__value_sha256, digest)),
)
else:
await confirm_metadata(
"op_data",
TR.tr("stellar__clear_data"),
TR.tr("stellar__wanna_clean_value_key_template"),
TR.stellar__clear_data,
TR.stellar__wanna_clean_value_key_template,
op.key,
)
@ -191,14 +187,14 @@ async def confirm_path_payment_strict_receive_op(
await confirm_output(
op.destination_account,
format_amount(op.destination_amount, op.destination_asset),
title=TR.tr("stellar__path_pay"),
title=TR.stellar__path_pay,
)
await confirm_asset_issuer(op.destination_asset)
# confirm what the sender is using to pay
await confirm_amount(
TR.tr("stellar__debited_amount"),
TR.stellar__debited_amount,
format_amount(op.send_max, op.send_asset),
TR.tr("stellar__pay_at_most"),
TR.stellar__pay_at_most,
"op_path_payment_strict_receive",
)
await confirm_asset_issuer(op.send_asset)
@ -210,14 +206,14 @@ async def confirm_path_payment_strict_send_op(
await confirm_output(
op.destination_account,
format_amount(op.destination_min, op.destination_asset),
title=TR.tr("stellar__path_pay_at_least"),
title=TR.stellar__path_pay_at_least,
)
await confirm_asset_issuer(op.destination_asset)
# confirm what the sender is using to pay
await confirm_amount(
TR.tr("stellar__debited_amount"),
TR.stellar__debited_amount,
format_amount(op.send_amount, op.send_asset),
TR.tr("stellar__pay"),
TR.stellar__pay,
"op_path_payment_strict_send",
)
await confirm_asset_issuer(op.send_asset)
@ -239,40 +235,38 @@ async def confirm_set_options_op(op: StellarSetOptionsOp) -> None:
if op.inflation_destination_account:
await confirm_address(
TR.tr("stellar__inflation"),
TR.stellar__inflation,
op.inflation_destination_account,
TR.tr("stellar__destination"),
TR.stellar__destination,
"op_inflation",
)
if op.clear_flags:
t = _format_flags(op.clear_flags)
await confirm_text("op_set_options", TR.tr("stellar__clear_flags"), data=t)
await confirm_text("op_set_options", TR.stellar__clear_flags, data=t)
if op.set_flags:
t = _format_flags(op.set_flags)
await confirm_text("op_set_options", TR.tr("stellar__set_flags"), data=t)
await confirm_text("op_set_options", TR.stellar__set_flags, data=t)
thresholds: list[tuple[str, str]] = []
append = thresholds.append # local_cache_attribute
if op.master_weight is not None:
append((TR.tr("stellar__master_weight"), str(op.master_weight)))
append((TR.stellar__master_weight, str(op.master_weight)))
if op.low_threshold is not None:
append((TR.tr("stellar__low"), str(op.low_threshold)))
append((TR.stellar__low, str(op.low_threshold)))
if op.medium_threshold is not None:
append((TR.tr("stellar__medium"), str(op.medium_threshold)))
append((TR.stellar__medium, str(op.medium_threshold)))
if op.high_threshold is not None:
append((TR.tr("stellar__high"), str(op.high_threshold)))
append((TR.stellar__high, str(op.high_threshold)))
if thresholds:
await confirm_properties(
"op_thresholds", TR.tr("stellar__account_thresholds"), thresholds
"op_thresholds", TR.stellar__account_thresholds, thresholds
)
if op.home_domain:
await confirm_text(
"op_home_domain", TR.tr("stellar__home_domain"), op.home_domain
)
await confirm_text("op_home_domain", TR.stellar__home_domain, op.home_domain)
signer_type = op.signer_type # local_cache_attribute
signer_key = op.signer_key # local_cache_attribute
@ -281,18 +275,18 @@ async def confirm_set_options_op(op: StellarSetOptionsOp) -> None:
raise DataError("Stellar: invalid signer option data.")
if op.signer_weight > 0:
title = TR.tr("stellar__add_signer")
title = TR.stellar__add_signer
else:
title = TR.tr("stellar__remove_signer")
title = TR.stellar__remove_signer
data: str | bytes = ""
if signer_type == StellarSignerType.ACCOUNT:
description = f"{TR.tr('stellar__account')}:"
description = f"{TR.stellar__account}:"
data = helpers.address_from_public_key(signer_key)
elif signer_type == StellarSignerType.PRE_AUTH:
description = TR.tr("stellar__preauth_transaction")
description = TR.stellar__preauth_transaction
data = signer_key
elif signer_type == StellarSignerType.HASH:
description = TR.tr("stellar__hash")
description = TR.stellar__hash
data = signer_key
else:
raise ProcessError("Stellar: invalid signer type")
@ -328,8 +322,8 @@ async def confirm_asset_issuer(asset: StellarAsset) -> None:
if asset.issuer is None or asset.code is None:
raise DataError("Stellar: invalid asset definition")
await confirm_address(
TR.tr("stellar__confirm_issuer"),
TR.stellar__confirm_issuer,
asset.issuer,
TR.tr("stellar__issuer_template").format(asset.code),
TR.stellar__issuer_template.format(asset.code),
"confirm_asset_issuer",
)

@ -1,4 +1,4 @@
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import ButtonRequestType
from trezor.ui.layouts import confirm_address, confirm_metadata, confirm_properties
@ -22,15 +22,15 @@ async def require_confirm_fee(value: int, fee: int) -> None:
await confirm_total(
format_tezos_amount(value),
format_tezos_amount(fee),
total_label=TR.tr("tezos__amount"),
total_label=TR.tezos__amount,
)
async def require_confirm_origination(address: str) -> None:
await confirm_address(
TR.tr("tezos__confirm_origination"),
TR.tezos__confirm_origination,
address,
TR.tr("tezos__address"),
TR.tezos__address,
"confirm_origination",
BR_SIGN_TX,
)
@ -39,10 +39,10 @@ async def require_confirm_origination(address: str) -> None:
async def require_confirm_origination_fee(balance: int, fee: int) -> None:
await confirm_properties(
"confirm_origination_final",
TR.tr("tezos__confirm_origination"),
TR.tezos__confirm_origination,
(
(TR.tr("tezos__balance"), format_tezos_amount(balance)),
(TR.tr("tezos__fee"), format_tezos_amount(fee)),
(TR.tezos__balance, format_tezos_amount(balance)),
(TR.tezos__fee, format_tezos_amount(fee)),
),
hold=True,
)
@ -50,9 +50,9 @@ async def require_confirm_origination_fee(balance: int, fee: int) -> None:
async def require_confirm_delegation_baker(baker: str) -> None:
await confirm_address(
TR.tr("tezos__confirm_delegation"),
TR.tezos__confirm_delegation,
baker,
TR.tr("tezos__baker_address"),
TR.tezos__baker_address,
"confirm_delegation",
BR_SIGN_TX,
)
@ -61,8 +61,8 @@ async def require_confirm_delegation_baker(baker: str) -> None:
async def require_confirm_set_delegate(fee: int) -> None:
await confirm_metadata(
"confirm_delegation_final",
TR.tr("tezos__confirm_delegation"),
TR.tr("tezos__fee") + "\n{}",
TR.tezos__confirm_delegation,
TR.tezos__fee + "\n{}",
format_tezos_amount(fee),
BR_SIGN_TX,
hold=True,
@ -72,10 +72,10 @@ async def require_confirm_set_delegate(fee: int) -> None:
async def require_confirm_register_delegate(address: str, fee: int) -> None:
await confirm_properties(
"confirm_register_delegate",
TR.tr("tezos__register_delegate"),
TR.tezos__register_delegate,
(
(TR.tr("tezos__fee"), format_tezos_amount(fee)),
(TR.tr("tezos__address"), address),
(TR.tezos__fee, format_tezos_amount(fee)),
(TR.tezos__address, address),
),
hold=True,
br_code=BR_SIGN_TX,
@ -94,10 +94,10 @@ def format_tezos_amount(value: int) -> str:
async def require_confirm_ballot(proposal: str, ballot: str) -> None:
await confirm_properties(
"confirm_ballot",
TR.tr("tezos__submit_ballot"),
TR.tezos__submit_ballot,
(
(TR.tr("tezos__ballot"), ballot),
(f"{TR.tr('tezos__proposal')}:", proposal),
(TR.tezos__ballot, ballot),
(f"{TR.tezos__proposal}:", proposal),
),
hold=True,
br_code=BR_SIGN_TX,
@ -107,11 +107,9 @@ async def require_confirm_ballot(proposal: str, ballot: str) -> None:
async def require_confirm_proposals(proposals: list[str]) -> None:
await confirm_properties(
"confirm_proposals",
TR.tr("tezos__submit_proposals")
if len(proposals) > 1
else TR.tr("tezos__submit_proposal"),
TR.tezos__submit_proposals if len(proposals) > 1 else TR.tezos__submit_proposal,
[
(f"{TR.tr('tezos__proposal')} " + str(i), proposal)
(f"{TR.tezos__proposal} " + str(i), proposal)
for i, proposal in enumerate(proposals, 1)
],
hold=True,
@ -121,9 +119,9 @@ async def require_confirm_proposals(proposals: list[str]) -> None:
async def require_confirm_delegation_manager_withdraw(address: str) -> None:
await confirm_address(
TR.tr("tezos__remove_delegation"),
TR.tezos__remove_delegation,
address,
TR.tr("tezos__delegator"),
TR.tezos__delegator,
"confirm_undelegation",
BR_SIGN_TX,
)
@ -132,8 +130,8 @@ async def require_confirm_delegation_manager_withdraw(address: str) -> None:
async def require_confirm_manager_remove_delegate(fee: int) -> None:
await confirm_metadata(
"confirm_undelegation_final",
TR.tr("tezos__remove_delegation"),
TR.tr("tezos__fee") + "\n{}",
TR.tezos__remove_delegation,
TR.tezos__fee + "\n{}",
format_tezos_amount(fee),
BR_SIGN_TX,
hold=True,

@ -6,7 +6,7 @@ if TYPE_CHECKING:
async def add_resident_credential(msg: WebAuthnAddResidentCredential) -> Success:
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor import wire
from trezor.messages import Success
from trezor.ui.layouts import show_error_and_raise
@ -25,11 +25,11 @@ async def add_resident_credential(msg: WebAuthnAddResidentCredential) -> Success
except Exception:
await show_error_and_raise(
"warning_credential",
TR.tr("fido__does_not_belong"),
TR.fido__does_not_belong,
)
await confirm_fido(
TR.tr("fido__title_import_credential"),
TR.fido__title_import_credential,
cred.app_name(),
cred.icon_name(),
[cred.account_name()],

@ -5,7 +5,7 @@ from micropython import const
from typing import TYPE_CHECKING
import storage.device as storage_device
import trezortranslate as TR
from trezortranslate import TR
from trezor import config, io, log, loop, utils, wire, workflow
from trezor.crypto import hashlib
from trezor.crypto.curve import nist256p1
@ -617,15 +617,15 @@ async def _confirm_bogus_app(title: str) -> None:
if _last_auth_valid:
await show_error_popup(
title,
TR.tr("fido__device_already_registered"),
TR.tr("fido__already_registered"),
TR.fido__device_already_registered,
TR.fido__already_registered,
timeout_ms=_POPUP_TIMEOUT_MS,
)
else:
await show_error_popup(
title,
TR.tr("fido__device_not_registered"),
TR.tr("fido__not_registered"),
TR.fido__device_not_registered,
TR.fido__not_registered,
timeout_ms=_POPUP_TIMEOUT_MS,
)
@ -685,7 +685,7 @@ class U2fConfirmRegister(U2fState):
await _confirm_bogus_app("U2F")
return False
else:
return await _confirm_fido(TR.tr("fido__title_u2f_register"), self._cred)
return await _confirm_fido(TR.fido__title_u2f_register, self._cred)
def __eq__(self, other: object) -> bool:
return (
@ -695,7 +695,7 @@ class U2fConfirmRegister(U2fState):
class U2fConfirmAuthenticate(U2fState):
async def confirm_dialog(self) -> bool:
return await _confirm_fido(TR.tr("fido__title_u2f_auth"), self._cred)
return await _confirm_fido(TR.fido__title_u2f_auth, self._cred)
def __eq__(self, other: object) -> bool:
return (
@ -804,7 +804,7 @@ class Fido2ConfirmMakeCredential(Fido2State):
if self._cred.rp_id == _BOGUS_RP_ID:
await _confirm_bogus_app("FIDO2")
return True
if not await _confirm_fido(TR.tr("fido__title_register"), self._cred):
if not await _confirm_fido(TR.fido__title_register, self._cred):
return False
if self._user_verification:
return await verify_user(KeepaliveCallback(self.cid, self.iface))
@ -840,9 +840,9 @@ class Fido2ConfirmExcluded(Fido2ConfirmMakeCredential):
self.finished = True
await show_error_popup(
TR.tr("fido__title_register"),
TR.tr("fido__device_already_registered_with_template"),
TR.tr("fido__already_registered"),
TR.fido__title_register,
TR.fido__device_already_registered_with_template,
TR.fido__already_registered,
self._cred.rp_id, # description_param
timeout_ms=_POPUP_TIMEOUT_MS,
)
@ -870,9 +870,7 @@ class Fido2ConfirmGetAssertion(Fido2State):
async def confirm_dialog(self) -> bool:
# There is a choice from more than one credential.
try:
index = await _confirm_fido_choose(
TR.tr("fido__title_authenticate"), self._creds
)
index = await _confirm_fido_choose(TR.fido__title_authenticate, self._creds)
except wire.ActionCancelled:
return False
@ -925,9 +923,9 @@ class Fido2ConfirmNoPin(State):
self.finished = True
await show_error_popup(
TR.tr("fido__title_verify_user"),
TR.tr("fido__please_enable_pin_protection"),
TR.tr("fido__unable_to_verify_user"),
TR.fido__title_verify_user,
TR.fido__please_enable_pin_protection,
TR.fido__unable_to_verify_user,
timeout_ms=_POPUP_TIMEOUT_MS,
)
return False
@ -948,9 +946,9 @@ class Fido2ConfirmNoCredentials(Fido2ConfirmGetAssertion):
self.finished = True
await show_error_popup(
TR.tr("fido__title_authenticate"),
TR.tr("fido__not_registered_with_template"),
TR.tr("fido__not_registered"),
TR.fido__title_authenticate,
TR.fido__not_registered_with_template,
TR.fido__not_registered,
self._creds[0].app_name(), # description_param
timeout_ms=_POPUP_TIMEOUT_MS,
)

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def list_resident_credentials(
msg: WebAuthnListResidentCredentials,
) -> WebAuthnCredentials:
import trezortranslate as TR
from trezortranslate import TR
from trezor.messages import WebAuthnCredential, WebAuthnCredentials
from trezor.ui.layouts import confirm_action
@ -15,9 +15,9 @@ async def list_resident_credentials(
await confirm_action(
"credentials_list",
TR.tr("fido__title_list_credentials"),
description=TR.tr("fido__export_credentials"),
verb=TR.tr("buttons__export"),
TR.fido__title_list_credentials,
description=TR.fido__export_credentials,
verb=TR.buttons__export,
)
creds = [
WebAuthnCredential(

@ -7,7 +7,7 @@ if TYPE_CHECKING:
async def remove_resident_credential(msg: WebAuthnRemoveResidentCredential) -> Success:
import storage.device
import storage.resident_credentials
import trezortranslate as TR
from trezortranslate import TR
from trezor import wire
from trezor.messages import Success
from trezor.ui.layouts.fido import confirm_fido
@ -24,7 +24,7 @@ async def remove_resident_credential(msg: WebAuthnRemoveResidentCredential) -> S
raise wire.ProcessError("Invalid credential index.")
await confirm_fido(
TR.tr("fido__title_remove_credential"),
TR.fido__title_remove_credential,
cred.app_name(),
cred.icon_name(),
[cred.account_name()],

@ -119,7 +119,7 @@ def set_label(label: str) -> None:
def get_language() -> str:
import trezortranslate as TR
from trezortranslate import language_name
language = common.get(_NAMESPACE, _LANGUAGE, True) # public
if language:
@ -127,7 +127,7 @@ def get_language() -> str:
# After storage wipe, language can still be set in translations area.
# In that case, saving it to the storage for the next quick retrieval.
translation_lang = TR.language_name()
translation_lang = language_name()
if translation_lang:
set_language(translation_lang)
return translation_lang

@ -39,7 +39,7 @@ def render_empty_loader(message: str, description: str) -> None:
def show_pin_timeout(seconds: int, progress: int, message: str) -> bool:
import trezortranslate as TR
from trezortranslate import TR
from trezor.ui.layouts.progress import pin_progress
# Possibility to ignore certain messages - not showing loader for them
@ -59,11 +59,11 @@ def show_pin_timeout(seconds: int, progress: int, message: str) -> bool:
if seconds != _previous_seconds:
if seconds == 0:
remaining = TR.tr("progress__done")
remaining = TR.progress__done
elif seconds == 1:
remaining = TR.tr("progress__one_second_left")
remaining = TR.progress__one_second_left
else:
remaining = TR.tr("progress__x_seconds_left_template").format(seconds)
remaining = TR.progress__x_seconds_left_template.format(seconds)
_previous_remaining = remaining
_previous_seconds = seconds
else:

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor import io, loop, ui
from trezor.enums import ButtonRequestType
@ -269,7 +269,7 @@ async def _placeholder_confirm(
hold: bool = False,
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> Any:
verb = verb or TR.tr("buttons__confirm") # def_arg
verb = verb or TR.buttons__confirm # def_arg
return await confirm_action(
br_type,
title.upper(),
@ -293,7 +293,7 @@ async def get_bool(
hold: bool = False,
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> bool:
verb = verb or TR.tr("buttons__confirm") # def_arg
verb = verb or TR.buttons__confirm # def_arg
result = await interact(
RustLayout(
trezorui2.confirm_action(
@ -333,7 +333,7 @@ async def confirm_action(
exc: ExceptionType = ActionCancelled,
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None:
verb = verb or TR.tr("buttons__confirm") # def_arg
verb = verb or TR.buttons__confirm # def_arg
if verb_cancel is not None:
verb_cancel = verb_cancel.upper()
@ -373,7 +373,7 @@ async def confirm_single(
br_type,
title,
description=begin + description_param + end,
verb=verb or TR.tr("buttons__confirm"),
verb=verb or TR.buttons__confirm,
br_code=ButtonRequestType.ProtectCall,
)
@ -383,9 +383,9 @@ async def confirm_reset_device(
recovery: bool = False,
) -> None:
if recovery:
button = TR.tr("reset__button_recover")
button = TR.reset__button_recover
else:
button = TR.tr("reset__button_create")
button = TR.reset__button_create
await raise_if_not_confirmed(
interact(
@ -417,10 +417,10 @@ async def prompt_backup() -> bool:
return await get_bool(
br_type,
TR.tr("backup__title_skip"),
description=TR.tr("backup__want_to_skip"),
verb=TR.tr("buttons__back_up"),
verb_cancel=TR.tr("buttons__skip"),
TR.backup__title_skip,
description=TR.backup__want_to_skip,
verb=TR.buttons__back_up,
verb_cancel=TR.buttons__skip,
br_code=br_code,
)
@ -429,7 +429,7 @@ async def confirm_path_warning(
path: str,
path_type: str | None = None,
) -> None:
title = f"{TR.tr('words__unknown')} {path_type if path_type else 'path'}"
title = f"{TR.words__unknown} {path_type if path_type else 'path'}"
return await _placeholder_confirm(
"path_warning",
title.upper(),
@ -445,7 +445,7 @@ async def confirm_homescreen(
interact(
RustLayout(
trezorui2.confirm_homescreen(
title=TR.tr("homescreen__title_set"),
title=TR.homescreen__title_set,
image=image,
)
),
@ -471,11 +471,11 @@ async def show_address(
br_code: ButtonRequestType = ButtonRequestType.Address,
chunkify: bool = False,
) -> None:
mismatch_title = mismatch_title or TR.tr("addr_mismatch__title") # def_arg
mismatch_title = mismatch_title or TR.addr_mismatch__title # def_arg
send_button_request = True
if title is None:
# Will be a marquee in case of multisig
title = TR.tr("address__title_receive_address")
title = TR.address__title_receive_address
if multisig_index is not None:
title = f"{title} (MULTISIG)"
while True:
@ -508,9 +508,9 @@ async def show_address(
# Will be marquee (cannot fit one line)
result = f"MULTISIG XPUB #{i + 1}"
result += (
f" ({TR.tr('address__title_yours')})"
f" ({TR.address__title_yours})"
if i == multisig_index
else f" ({TR.tr('address__title_cosigner')})"
else f" ({TR.address__title_cosigner})"
)
return result
@ -550,10 +550,8 @@ def show_pubkey(
mismatch_title: str | None = None,
br_type: str = "show_pubkey",
) -> Awaitable[None]:
title = title or TR.tr("address__public_key") # def_arg
mismatch_title = mismatch_title or TR.tr(
"addr_mismatch__title_key_mismatch"
) # def_arg
title = title or TR.address__public_key # def_arg
mismatch_title = mismatch_title or TR.addr_mismatch__title_key_mismatch # def_arg
return show_address(
address=pubkey,
title=title.upper(),
@ -595,7 +593,7 @@ async def show_error_and_raise(
button: str | None = None,
exc: ExceptionType = ActionCancelled,
) -> NoReturn:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await show_warning(
br_type,
subheader or "",
@ -613,7 +611,7 @@ async def show_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__continue") # def_arg
button = button or TR.buttons__continue # def_arg
await interact(
RustLayout(
trezorui2.show_warning( # type: ignore [Argument missing for parameter "title"]
@ -633,8 +631,8 @@ def show_success(
subheader: str | None = None,
button: str | None = None,
) -> Awaitable[None]:
button = button or TR.tr("buttons__continue") # def_arg
title = TR.tr("words__title_success")
button = button or TR.buttons__continue # def_arg
title = TR.words__title_success
# In case only subheader is supplied, showing it
# in regular font, not bold.
@ -644,7 +642,7 @@ def show_success(
# Special case for Shamir backup - to show everything just on one page
# in regular font.
if TR.tr("words__continue_with") in content:
if TR.words__continue_with in content:
content = f"{subheader}\n\n{content}"
subheader = None
title = ""
@ -670,11 +668,11 @@ async def confirm_output(
output_index: int | None = None,
chunkify: bool = False,
) -> None:
title = title or TR.tr("send__confirm_sending") # def_arg
address_title = TR.tr("send__title_recipient")
title = title or TR.send__confirm_sending # def_arg
address_title = TR.send__title_recipient
if output_index is not None:
address_title += f" #{output_index + 1}"
amount_title = TR.tr("send__title_amount")
amount_title = TR.send__title_amount
if output_index is not None:
amount_title += f" #{output_index + 1}"
@ -729,7 +727,7 @@ async def confirm_payment_request(
memos_str = "\n".join(memos)
return await _placeholder_confirm(
"confirm_payment_request",
TR.tr("send__title_confirm_sending"),
TR.send__title_confirm_sending,
description=f"{amount} to\n{recipient_name}\n{memos_str}",
br_code=ButtonRequestType.ConfirmOutput,
)
@ -749,9 +747,9 @@ async def should_show_more(
Raises ActionCancelled if the user cancels.
"""
button_text = button_text or TR.tr("buttons__show_all") # def_arg
button_text = button_text or TR.buttons__show_all # def_arg
if confirm is None or not isinstance(confirm, str):
confirm = TR.tr("buttons__confirm")
confirm = TR.buttons__confirm
result = await interact(
RustLayout(
@ -787,7 +785,7 @@ async def confirm_blob(
br_code: ButtonRequestType = BR_TYPE_OTHER,
ask_pagination: bool = False,
) -> None:
verb = verb or TR.tr("buttons__confirm") # def_arg
verb = verb or TR.buttons__confirm # def_arg
title = title.upper()
description = description or ""
layout = RustLayout(
@ -846,7 +844,7 @@ async def _confirm_ask_pagination(
paginated = RustLayout(
trezorui2.confirm_more(
title=title,
button=TR.tr("buttons__go_back"),
button=TR.buttons__go_back,
items=[(ui.BOLD, f"Size: {len(data)} bytes"), (ui.MONO, data)],
)
)
@ -866,7 +864,7 @@ async def confirm_address(
br_type: str = "confirm_address",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> Awaitable[None]:
description = description or TR.tr("address__address") # def_arg
description = description or TR.address__address # def_arg
return confirm_blob(
br_type,
title.upper(),
@ -899,7 +897,7 @@ def confirm_amount(
br_type: str = "confirm_amount",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> Awaitable[None]:
description = description or TR.tr("send__amount") # def_arg
description = description or TR.send__amount # def_arg
return confirm_blob(
br_type,
title.upper(),
@ -967,7 +965,7 @@ def confirm_value(
title=title.upper(),
description=description,
value=value,
verb=verb or TR.tr("buttons__hold_to_confirm"),
verb=verb or TR.buttons__hold_to_confirm,
hold=hold,
)
),
@ -988,8 +986,8 @@ async def confirm_total(
br_type: str = "confirm_total",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
total_label = total_label or TR.tr("send__total_amount") # def_arg
fee_label = fee_label or TR.tr("send__including_fee") # def_arg
total_label = total_label or TR.send__total_amount # def_arg
fee_label = fee_label or TR.send__including_fee # def_arg
await raise_if_not_confirmed(
interact(
RustLayout(
@ -1069,10 +1067,10 @@ async def confirm_replacement(description: str, txid: str) -> None:
await confirm_value(
description.upper(),
txid,
TR.tr("send__transaction_id"),
TR.send__transaction_id,
"confirm_replacement",
ButtonRequestType.SignTx,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
)
@ -1148,7 +1146,7 @@ async def confirm_sign_identity(
await _placeholder_confirm(
"confirm_sign_identity",
f"{TR.tr('words__sign')} {proto}".upper(),
f"{TR.words__sign} {proto}".upper(),
text,
br_code=BR_TYPE_OTHER,
)
@ -1163,16 +1161,16 @@ async def confirm_signverify(
while True:
await confirm_blob(
br_type,
TR.tr("sign_message__confirm_address"),
TR.sign_message__confirm_address,
address,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
br_code=BR_TYPE_OTHER,
)
try:
await confirm_blob(
br_type,
TR.tr("sign_message__confirm_message"),
TR.sign_message__confirm_message,
message,
verb_cancel="^",
br_code=BR_TYPE_OTHER,
@ -1215,7 +1213,7 @@ async def request_passphrase_on_device(max_len: int) -> str:
result = await interact(
RustLayout(
trezorui2.request_passphrase(
prompt=TR.tr("passphrase__title_enter"),
prompt=TR.passphrase__title_enter,
max_len=max_len,
)
),
@ -1242,9 +1240,9 @@ async def request_pin_on_device(
if attempts_remaining is None or attempts_remaining == 16:
subprompt = ""
elif attempts_remaining == 1:
subprompt = TR.tr("pin__last_attempt")
subprompt = TR.pin__last_attempt
else:
subprompt = f"{attempts_remaining} {TR.tr('pin__tries_left')}"
subprompt = f"{attempts_remaining} {TR.pin__tries_left}"
result = await interact(
RustLayout(
@ -1269,21 +1267,15 @@ async def confirm_reenter_pin(
is_wipe_code: bool = False,
) -> None:
br_type = "reenter_wipe_code" if is_wipe_code else "reenter_pin"
title = (
TR.tr("wipe_code__title_check")
if is_wipe_code
else TR.tr("pin__title_check_pin")
)
title = TR.wipe_code__title_check if is_wipe_code else TR.pin__title_check_pin
description = (
TR.tr("wipe_code__reenter_to_confirm")
if is_wipe_code
else TR.tr("pin__reenter_to_confirm")
TR.wipe_code__reenter_to_confirm if is_wipe_code else TR.pin__reenter_to_confirm
)
return await confirm_action(
br_type,
title,
description=description,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
verb_cancel=None,
br_code=BR_TYPE_OTHER,
)
@ -1314,15 +1306,13 @@ async def _confirm_multiple_pages_texts(
async def pin_mismatch_popup(
is_wipe_code: bool = False,
) -> None:
description = (
TR.tr("wipe_code__mismatch") if is_wipe_code else TR.tr("pin__mismatch")
)
description = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch
br_code = "wipe_code_mismatch" if is_wipe_code else "pin_mismatch"
return await show_warning(
br_code,
description,
TR.tr("pin__please_check_again"),
TR.tr("buttons__check_again"),
TR.pin__please_check_again,
TR.buttons__check_again,
BR_TYPE_OTHER,
)
@ -1330,9 +1320,9 @@ async def pin_mismatch_popup(
async def wipe_code_same_as_pin_popup() -> None:
return await confirm_action(
"wipe_code_same_as_pin",
TR.tr("wipe_code__title_invalid"),
description=TR.tr("wipe_code__diff_from_pin"),
verb=TR.tr("buttons__try_again"),
TR.wipe_code__title_invalid,
description=TR.wipe_code__diff_from_pin,
verb=TR.buttons__try_again,
verb_cancel=None,
br_code=BR_TYPE_OTHER,
)
@ -1349,7 +1339,7 @@ async def confirm_set_new_pin(
br_type,
title.upper(),
[description, information],
TR.tr("buttons__turn_on"),
TR.buttons__turn_on,
br_code,
)
@ -1359,13 +1349,13 @@ async def confirm_set_new_pin(
# Additional information for the user to know about PIN
next_info = [
TR.tr("pin__should_be_long"),
TR.tr("pin__cursor_will_change"),
TR.pin__should_be_long,
TR.pin__cursor_will_change,
]
await _confirm_multiple_pages_texts(
br_type,
title.upper(),
next_info,
TR.tr("buttons__continue"),
TR.buttons__continue,
br_code,
)

@ -38,15 +38,15 @@ async def confirm_fido(
async def confirm_fido_reset() -> bool:
import trezortranslate as TR
from trezortranslate import TR
confirm = RustLayout(
trezorui2.confirm_action(
title=TR.tr("fido__title_reset"),
description=TR.tr("fido__wanna_erase_credentials"),
title=TR.fido__title_reset,
description=TR.fido__wanna_erase_credentials,
action=None,
verb_cancel="",
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)
)
return (await confirm) is trezorui2.CONFIRMED

@ -105,12 +105,12 @@ class Busyscreen(HomescreenBase):
RENDER_INDICATOR = storage_cache.BUSYSCREEN_ON
def __init__(self, delay_ms: int) -> None:
import trezortranslate as TR
from trezortranslate import TR
skip = storage_cache.homescreen_shown is self.RENDER_INDICATOR
super().__init__(
layout=trezorui2.show_progress_coinjoin(
title=TR.tr("coinjoin__waiting_for_others"),
title=TR.coinjoin__waiting_for_others,
indeterminate=True,
time_ms=delay_ms,
skip_first_paint=skip,

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor import ui
@ -34,7 +34,7 @@ def progress(
description: str | None = None,
indeterminate: bool = False,
) -> ProgressLayout:
message = message or TR.tr("progress__please_wait") # def_arg
message = message or TR.progress__please_wait # def_arg
return RustProgress(
layout=trezorui2.show_progress(
title=message.upper(),
@ -59,12 +59,12 @@ def pin_progress(message: str, description: str) -> ProgressLayout:
def monero_keyimage_sync_progress() -> ProgressLayout:
return progress("", TR.tr("progress__syncing"))
return progress("", TR.progress__syncing)
def monero_live_refresh_progress() -> ProgressLayout:
return progress("", TR.tr("progress__refreshing"), indeterminate=True)
return progress("", TR.progress__refreshing, indeterminate=True)
def monero_transaction_progress_inner() -> ProgressLayout:
return progress("", TR.tr("progress__signing_transaction"))
return progress("", TR.progress__signing_transaction)

@ -1,6 +1,6 @@
from typing import Callable, Iterable
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor.enums import ButtonRequestType
@ -21,7 +21,7 @@ async def request_word_count(dry_run: bool) -> int:
async def request_word(word_index: int, word_count: int, is_slip39: bool) -> str:
from trezor.wire.context import wait
prompt = TR.tr("recovery__word_x_of_y_template").format(word_index + 1, word_count)
prompt = TR.recovery__word_x_of_y_template.format(word_index + 1, word_count)
if is_slip39:
word_choice = RustLayout(trezorui2.request_slip39(prompt=prompt))
@ -46,10 +46,10 @@ async def show_group_share_success(share_index: int, group_index: int) -> None:
RustLayout(
trezorui2.show_group_share_success(
lines=[
TR.tr("recovery__you_have_entered"),
TR.tr("recovery__share_num_template").format(share_index + 1),
TR.tr("words__from"),
TR.tr("recovery__group_num_template").format(group_index + 1),
TR.recovery__you_have_entered,
TR.recovery__share_num_template.format(share_index + 1),
TR.words__from,
TR.recovery__group_num_template.format(group_index + 1),
],
)
),
@ -103,5 +103,5 @@ async def show_recovery_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await show_warning(br_type, content, subheader, button, br_code)

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor.enums import ButtonRequestType
from trezor.wire import ActionCancelled
@ -26,14 +26,14 @@ async def show_share_words(
br_code = ButtonRequestType.ResetDevice
if share_index is None:
title = TR.tr("reset__share_words_title")
check_title = TR.tr("reset__check_backup_title")
title = TR.reset__share_words_title
check_title = TR.reset__check_backup_title
elif group_index is None:
title = f"{TR.tr('words__title_share')} #{share_index + 1}"
check_title = f"{TR.tr('words__title_check')} {TR.tr('words__title_share')} #{share_index + 1}"
title = f"{TR.words__title_share} #{share_index + 1}"
check_title = f"{TR.words__title_check} {TR.words__title_share} #{share_index + 1}"
else:
title = f"{TR.tr('words__title_group')} {group_index + 1} - {TR.tr('words__title_share')} {share_index + 1}"
check_title = f"{TR.tr('words__title_group')} {group_index + 1} - {TR.tr('words__title_share')} {share_index + 1}"
title = f"{TR.words__title_group} {group_index + 1} - {TR.words__title_share} {share_index + 1}"
check_title = f"{TR.words__title_group} {group_index + 1} - {TR.words__title_share} {share_index + 1}"
# We want the option to go back from words to the previous screen
# (by sending CANCELLED)
@ -41,10 +41,8 @@ async def show_share_words(
await confirm_action(
br_type,
title,
description=TR.tr("reset__write_down_words_template").format(
len(share_words)
),
verb=TR.tr("buttons__show_words"),
description=TR.reset__write_down_words_template.format(len(share_words)),
verb=TR.buttons__show_words,
verb_cancel=None,
br_code=br_code,
)
@ -64,8 +62,8 @@ async def show_share_words(
await confirm_action(
br_type,
check_title,
description=TR.tr("reset__select_correct_word"),
verb=TR.tr("buttons__continue"),
description=TR.reset__select_correct_word,
verb=TR.buttons__continue,
verb_cancel=None,
br_code=br_code,
)
@ -93,7 +91,7 @@ async def select_word(
RustLayout(
trezorui2.select_word(
title="",
description=TR.tr("reset__select_word_template").format(word_ordinal),
description=TR.reset__select_word_template.format(word_ordinal),
words=(words[0].lower(), words[1].lower(), words[2].lower()),
)
)
@ -111,23 +109,23 @@ async def slip39_show_checklist(step: int, backup_type: BackupType) -> None:
items = (
(
TR.tr("reset__slip39_checklist_num_shares"),
TR.tr("reset__slip39_checklist_set_threshold"),
TR.tr("reset__slip39_checklist_write_down"),
TR.reset__slip39_checklist_num_shares,
TR.reset__slip39_checklist_set_threshold,
TR.reset__slip39_checklist_write_down,
)
if backup_type == BackupType.Slip39_Basic
else (
TR.tr("reset__slip39_checklist_num_groups"),
TR.tr("reset__slip39_checklist_num_shares"),
TR.tr("reset__slip39_checklist_set_sizes"),
TR.reset__slip39_checklist_num_groups,
TR.reset__slip39_checklist_num_shares,
TR.reset__slip39_checklist_set_sizes,
)
)
result = await interact(
RustLayout(
trezorui2.show_checklist(
title=TR.tr("reset__slip39_checklist_title"),
button=TR.tr("buttons__continue"),
title=TR.reset__slip39_checklist_title,
button=TR.buttons__continue,
active=step,
items=items,
)
@ -169,9 +167,9 @@ async def slip39_prompt_threshold(
) -> int:
await confirm_action(
"slip39_prompt_threshold",
TR.tr("words__title_threshold"),
description=TR.tr("reset__threshold_info"),
verb=TR.tr("buttons__continue"),
TR.words__title_threshold,
description=TR.reset__threshold_info,
verb=TR.buttons__continue,
verb_cancel=None,
)
@ -182,9 +180,9 @@ async def slip39_prompt_threshold(
max_count = num_of_shares
if group_id is not None:
title = f"{TR.tr('words__title_threshold')} - {TR.tr('words__title_group')} {group_id + 1}"
title = f"{TR.words__title_threshold} - {TR.words__title_group} {group_id + 1}"
else:
title = TR.tr("words__title_threshold")
title = TR.words__title_threshold
return await _prompt_number(
title,
@ -198,9 +196,9 @@ async def slip39_prompt_threshold(
async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
await confirm_action(
"slip39_shares",
TR.tr("reset__title_number_of_shares"),
description=TR.tr("reset__number_of_shares_info"),
verb=TR.tr("buttons__continue"),
TR.reset__title_number_of_shares,
description=TR.reset__number_of_shares_info,
verb=TR.buttons__continue,
verb_cancel=None,
)
@ -209,9 +207,9 @@ async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
max_count = 16
if group_id is not None:
title = f"# {TR.tr('words__title_shares')} - {TR.tr('words__title_group')} {group_id + 1}"
title = f"# {TR.words__title_shares} - {TR.words__title_group} {group_id + 1}"
else:
title = TR.tr("reset__title_number_of_shares")
title = TR.reset__title_number_of_shares
return await _prompt_number(
title,
@ -228,7 +226,7 @@ async def slip39_advanced_prompt_number_of_groups() -> int:
max_count = 16
return await _prompt_number(
TR.tr("reset__title_number_of_groups"),
TR.reset__title_number_of_groups,
count,
min_count,
max_count,
@ -242,7 +240,7 @@ async def slip39_advanced_prompt_group_threshold(num_of_groups: int) -> int:
max_count = num_of_groups
return await _prompt_number(
TR.tr("reset__title_group_threshold"),
TR.reset__title_group_threshold,
count,
min_count,
max_count,
@ -253,9 +251,9 @@ async def slip39_advanced_prompt_group_threshold(num_of_groups: int) -> int:
async def show_warning_backup(slip39: bool) -> None:
await show_warning(
"backup_warning",
TR.tr("words__title_remember"),
TR.tr("reset__never_make_digital_copy"),
TR.tr("buttons__ok_i_understand"),
TR.words__title_remember,
TR.reset__never_make_digital_copy,
TR.buttons__ok_i_understand,
ButtonRequestType.ResetDevice,
)
@ -263,9 +261,9 @@ async def show_warning_backup(slip39: bool) -> None:
async def show_success_backup() -> None:
await confirm_action(
"success_backup",
TR.tr("reset__title_backup_is_done"),
description=TR.tr("words__keep_it_safe"),
verb=TR.tr("buttons__continue"),
TR.reset__title_backup_is_done,
description=TR.words__keep_it_safe,
verb=TR.buttons__continue,
verb_cancel=None,
br_code=ButtonRequestType.Success,
)
@ -278,7 +276,7 @@ async def show_reset_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await show_warning(
br_type,

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor import io, loop, ui
from trezor.enums import ButtonRequestType
@ -307,9 +307,9 @@ async def confirm_single(
async def confirm_reset_device(title: str, recovery: bool = False) -> None:
if recovery:
button = TR.tr("reset__button_recover")
button = TR.reset__button_recover
else:
button = TR.tr("reset__button_create")
button = TR.reset__button_create
await raise_if_not_confirmed(
interact(
@ -332,11 +332,11 @@ async def prompt_backup() -> bool:
result = await interact(
RustLayout(
trezorui2.confirm_action(
title=TR.tr("words__title_success"),
action=TR.tr("backup__new_wallet_successfully_created"),
description=TR.tr("backup__it_should_be_backed_up"),
verb=TR.tr("buttons__back_up"),
verb_cancel=TR.tr("buttons__skip"),
title=TR.words__title_success,
action=TR.backup__new_wallet_successfully_created,
description=TR.backup__it_should_be_backed_up,
verb=TR.buttons__back_up,
verb_cancel=TR.buttons__skip,
)
),
"backup_device",
@ -348,11 +348,11 @@ async def prompt_backup() -> bool:
result = await interact(
RustLayout(
trezorui2.confirm_action(
title=TR.tr("words__warning").upper(),
action=TR.tr("backup__want_to_skip"),
description=TR.tr("backup__can_back_up_anytime"),
verb=TR.tr("buttons__back_up"),
verb_cancel=TR.tr("buttons__skip"),
title=TR.words__warning.upper(),
action=TR.backup__want_to_skip,
description=TR.backup__can_back_up_anytime,
verb=TR.buttons__back_up,
verb_cancel=TR.buttons__skip,
)
),
"backup_device",
@ -366,9 +366,9 @@ async def confirm_path_warning(
path_type: str | None = None,
) -> None:
title = (
TR.tr("addr_mismatch__wrong_derication_path")
TR.addr_mismatch__wrong_derication_path
if not path_type
else f"{TR.tr('words__unknown')} {path_type.lower()}."
else f"{TR.words__unknown} {path_type.lower()}."
)
await raise_if_not_confirmed(
interact(
@ -376,8 +376,8 @@ async def confirm_path_warning(
trezorui2.show_warning(
title=title,
value=path,
description=TR.tr("words__continue_anyway"),
button=TR.tr("buttons__continue"),
description=TR.words__continue_anyway,
button=TR.buttons__continue,
)
),
"path_warning",
@ -393,7 +393,7 @@ async def confirm_homescreen(
interact(
RustLayout(
trezorui2.confirm_homescreen(
title=TR.tr("homescreen__title_set"),
title=TR.homescreen__title_set,
image=image,
)
),
@ -419,14 +419,14 @@ async def show_address(
br_code: ButtonRequestType = ButtonRequestType.Address,
chunkify: bool = False,
) -> None:
mismatch_title = mismatch_title or TR.tr("addr_mismatch__title") # def_arg
mismatch_title = mismatch_title or TR.addr_mismatch__title # def_arg
send_button_request = True
if title is None:
title = TR.tr("address__title_receive_address")
title = TR.address__title_receive_address
if multisig_index is not None:
title = f"{title}\n(MULTISIG)"
details_title = TR.tr("send__title_receiving_to")
details_title = TR.send__title_receiving_to
else:
details_title = title
@ -459,9 +459,9 @@ async def show_address(
def xpub_title(i: int) -> str:
result = f"MULTISIG XPUB #{i + 1}\n"
result += (
f"({TR.tr('address__title_yours')})"
f"({TR.address__title_yours})"
if i == multisig_index
else f"({TR.tr('address__title_cosigner')})"
else f"({TR.address__title_cosigner})"
)
return result
@ -499,10 +499,8 @@ def show_pubkey(
mismatch_title: str | None = None,
br_type: str = "show_pubkey",
) -> Awaitable[None]:
title = title or TR.tr("address__public_key") # def_arg
mismatch_title = mismatch_title or TR.tr(
"addr_mismatch__title_key_mismatch"
) # def_arg
title = title or TR.address__public_key # def_arg
mismatch_title = mismatch_title or TR.addr_mismatch__title_key_mismatch # def_arg
return show_address(
address=pubkey,
title=title.upper(),
@ -522,7 +520,7 @@ async def show_error_and_raise(
button: str | None = None,
exc: ExceptionType = ActionCancelled,
) -> NoReturn:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await interact(
RustLayout(
trezorui2.show_error(
@ -545,7 +543,7 @@ async def show_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__continue") # def_arg
button = button or TR.buttons__continue # def_arg
await raise_if_not_confirmed(
interact(
RustLayout(
@ -567,7 +565,7 @@ async def show_success(
subheader: str | None = None,
button: str | None = None,
) -> None:
button = button or TR.tr("buttons__continue") # def_arg
button = button or TR.buttons__continue # def_arg
await raise_if_not_confirmed(
interact(
RustLayout(
@ -601,11 +599,11 @@ async def confirm_output(
amount_title = title.upper()
recipient_title = title.upper()
elif output_index is not None:
amount_title = f"{TR.tr('send__title_amount') } #{output_index + 1}"
recipient_title = f"{TR.tr('send__title_recipient')} #{output_index + 1}"
amount_title = f"{TR.send__title_amount } #{output_index + 1}"
recipient_title = f"{TR.send__title_recipient} #{output_index + 1}"
else:
amount_title = TR.tr("send__confirm_sending")
recipient_title = TR.tr("send__title_sending_to")
amount_title = TR.send__confirm_sending
recipient_title = TR.send__title_sending_to
while True:
result = await interact(
@ -615,7 +613,7 @@ async def confirm_output(
subtitle=address_label,
description=None,
value=address,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
hold=False,
info_button=False,
chunkify=chunkify,
@ -634,7 +632,7 @@ async def confirm_output(
subtitle=None,
description=None,
value=amount,
verb=None if hold else TR.tr("buttons__confirm"),
verb=None if hold else TR.buttons__confirm,
verb_cancel="^",
hold=hold,
info_button=False,
@ -655,11 +653,11 @@ async def confirm_payment_request(
result = await interact(
RustLayout(
trezorui2.confirm_with_info(
title=TR.tr("send__title_sending"),
title=TR.send__title_sending,
items=[(ui.NORMAL, f"{amount} to\n{recipient_name}")]
+ [(ui.NORMAL, memo) for memo in memos],
button=TR.tr("buttons__confirm"),
info_button=TR.tr("buttons__details"),
button=TR.buttons__confirm,
info_button=TR.buttons__details,
)
),
"confirm_payment_request",
@ -689,9 +687,9 @@ async def should_show_more(
Raises ActionCancelled if the user cancels.
"""
button_text = button_text or TR.tr("buttons__show_all") # def_arg
button_text = button_text or TR.buttons__show_all # def_arg
if confirm is None or not isinstance(confirm, str):
confirm = TR.tr("buttons__confirm")
confirm = TR.buttons__confirm
result = await interact(
RustLayout(
@ -741,7 +739,7 @@ async def _confirm_ask_pagination(
paginated = RustLayout(
trezorui2.confirm_more(
title=title,
button=TR.tr("buttons__close"),
button=TR.buttons__close,
items=[(ui.MONO, data)],
)
)
@ -765,7 +763,7 @@ async def confirm_blob(
br_code: ButtonRequestType = BR_TYPE_OTHER,
ask_pagination: bool = False,
) -> None:
verb = verb or TR.tr("buttons__confirm") # def_arg
verb = verb or TR.buttons__confirm # def_arg
title = title.upper()
description = description or ""
layout = RustLayout(
@ -797,7 +795,7 @@ async def confirm_blob(
async def confirm_address(
title: str,
address: str,
description: str | None = TR.tr("address__address"),
description: str | None = TR.address__address,
br_type: str = "confirm_address",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> None:
@ -807,7 +805,7 @@ async def confirm_address(
description or "",
br_type,
br_code,
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)
@ -824,7 +822,7 @@ async def confirm_text(
description or "",
br_type,
br_code,
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)
@ -835,14 +833,14 @@ def confirm_amount(
br_type: str = "confirm_amount",
br_code: ButtonRequestType = BR_TYPE_OTHER,
) -> Awaitable[None]:
description = description or TR.tr("send__amount") # def_arg
description = description or TR.send__amount # def_arg
return confirm_value(
title,
amount,
description,
br_type,
br_code,
verb=TR.tr("buttons__confirm"),
verb=TR.buttons__confirm,
)
@ -921,9 +919,9 @@ async def confirm_total(
br_type: str = "confirm_total",
br_code: ButtonRequestType = ButtonRequestType.SignTx,
) -> None:
title = title or TR.tr("words__title_summary") # def_arg
total_label = total_label or TR.tr("send__total_amount") # def_arg
fee_label = fee_label or TR.tr("send__including_fee") # def_arg
title = title or TR.words__title_summary # def_arg
total_label = total_label or TR.send__total_amount # def_arg
fee_label = fee_label or TR.send__including_fee # def_arg
total_layout = RustLayout(
trezorui2.confirm_total(
title=title,
@ -936,12 +934,12 @@ async def confirm_total(
)
items: list[tuple[str, str]] = []
if account_label:
items.append((TR.tr("confirm_total__sending_from_account"), account_label))
items.append((TR.confirm_total__sending_from_account, account_label))
if fee_rate_amount:
items.append((TR.tr("confirm_total__fee_rate"), fee_rate_amount))
items.append((TR.confirm_total__fee_rate, fee_rate_amount))
info_layout = RustLayout(
trezorui2.show_info_with_cancel(
title=TR.tr("confirm_total__title_information"),
title=TR.confirm_total__title_information,
items=items,
)
)
@ -958,10 +956,10 @@ async def confirm_ethereum_tx(
) -> None:
total_layout = RustLayout(
trezorui2.confirm_total(
title=TR.tr("words__title_summary"),
title=TR.words__title_summary,
items=[
(TR.tr("send__amount"), total_amount),
(TR.tr("send__maximum_fee"), maximum_fee),
(TR.send__amount, total_amount),
(TR.send__maximum_fee, maximum_fee),
],
info_button=True,
cancel_arrow=True,
@ -969,7 +967,7 @@ async def confirm_ethereum_tx(
)
info_layout = RustLayout(
trezorui2.show_info_with_cancel(
title=TR.tr("confirm_total__title_fee"),
title=TR.confirm_total__title_fee,
items=items,
)
)
@ -978,9 +976,9 @@ async def confirm_ethereum_tx(
# Allowing going back and forth between recipient and summary/details
await confirm_blob(
br_type,
TR.tr("send__title_recipient"),
TR.send__title_recipient,
recipient,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
)
try:
@ -996,10 +994,10 @@ async def confirm_joint_total(spending_amount: str, total_amount: str) -> None:
interact(
RustLayout(
trezorui2.confirm_total(
title=TR.tr("send__title_joint_transaction"),
title=TR.send__title_joint_transaction,
items=[
(TR.tr("send__you_are_contributing"), spending_amount),
(TR.tr("send__to_the_total_amount"), total_amount),
(TR.send__you_are_contributing, spending_amount),
(TR.send__to_the_total_amount, total_amount),
],
)
),
@ -1018,7 +1016,7 @@ async def confirm_metadata(
hold: bool = False,
verb: str | None = None,
) -> None:
verb = verb or TR.tr("buttons__continue") # def_arg
verb = verb or TR.buttons__continue # def_arg
await confirm_action(
br_type,
title=title.upper(),
@ -1035,8 +1033,8 @@ async def confirm_replacement(title: str, txid: str) -> None:
await confirm_blob(
title=title.upper(),
data=txid,
description=TR.tr("send__transaction_id"),
verb=TR.tr("buttons__continue"),
description=TR.send__transaction_id,
verb=TR.buttons__continue,
br_type="confirm_replacement",
br_code=ButtonRequestType.SignTx,
)
@ -1059,11 +1057,11 @@ async def confirm_modify_output(
ctx_wait(
RustLayout(
trezorui2.confirm_blob(
title=TR.tr("bitcoin__title_modify_amount"),
title=TR.bitcoin__title_modify_amount,
data=address,
verb=TR.tr("buttons__continue"),
verb=TR.buttons__continue,
verb_cancel=None,
description=TR.tr("address__address"),
description=TR.address__address,
extra=None,
)
)
@ -1132,10 +1130,10 @@ async def confirm_modify_fee(
)
items: list[tuple[str, str]] = []
if fee_rate_amount:
items.append((TR.tr("bitcoin__new_fee_rate"), fee_rate_amount))
items.append((TR.bitcoin__new_fee_rate, fee_rate_amount))
info_layout = RustLayout(
trezorui2.show_info_with_cancel(
title=TR.tr("confirm_total__title_fee"),
title=TR.confirm_total__title_fee,
items=items,
)
)
@ -1162,7 +1160,7 @@ async def confirm_sign_identity(
proto: str, identity: str, challenge_visual: str | None
) -> None:
await confirm_blob(
title=f"{TR.tr('words__sign')} {proto}",
title=f"{TR.words__sign} {proto}",
data=identity,
description=challenge_visual + "\n" if challenge_visual else "",
br_type="sign_identity",
@ -1177,14 +1175,14 @@ async def confirm_signverify(
await confirm_blob(
br_type,
TR.tr("sign_message__confirm_address"),
TR.sign_message__confirm_address,
address,
br_code=BR_TYPE_OTHER,
)
await confirm_blob(
br_type,
TR.tr("sign_message__confirm_message"),
TR.sign_message__confirm_message,
message,
hold=not verify,
br_code=BR_TYPE_OTHER,
@ -1220,7 +1218,7 @@ def request_passphrase_on_host() -> None:
draw_simple(
trezorui2.show_simple(
title=None,
description=TR.tr("passphrase__please_enter"),
description=TR.passphrase__please_enter,
)
)
@ -1229,7 +1227,7 @@ async def request_passphrase_on_device(max_len: int) -> str:
result = await interact(
RustLayout(
trezorui2.request_passphrase(
prompt=TR.tr("passphrase__title_enter"), max_len=max_len
prompt=TR.passphrase__title_enter, max_len=max_len
)
),
"passphrase_device",
@ -1253,9 +1251,9 @@ async def request_pin_on_device(
if attempts_remaining is None:
subprompt = ""
elif attempts_remaining == 1:
subprompt = TR.tr("pin__last_attempt")
subprompt = TR.pin__last_attempt
else:
subprompt = f"{attempts_remaining} {TR.tr('pin__tries_left')}"
subprompt = f"{attempts_remaining} {TR.pin__tries_left}"
result = await interact(
RustLayout(
@ -1286,27 +1284,21 @@ async def pin_mismatch_popup(
is_wipe_code: bool = False,
) -> None:
await button_request("pin_mismatch", code=BR_TYPE_OTHER)
title = (
TR.tr("wipe_code__wipe_code_mismatch")
if is_wipe_code
else TR.tr("pin__pin_mismatch")
)
description = (
TR.tr("wipe_code__mismatch") if is_wipe_code else TR.tr("pin__mismatch")
)
title = TR.wipe_code__wipe_code_mismatch if is_wipe_code else TR.pin__pin_mismatch
description = TR.wipe_code__mismatch if is_wipe_code else TR.pin__mismatch
return await show_error_popup(
title,
description,
button=TR.tr("buttons__try_again"),
button=TR.buttons__try_again,
)
async def wipe_code_same_as_pin_popup() -> None:
await button_request("wipe_code_same_as_pin", code=BR_TYPE_OTHER)
return await show_error_popup(
TR.tr("wipe_code__invalid"),
TR.tr("wipe_code__diff_from_pin"),
button=TR.tr("buttons__try_again"),
TR.wipe_code__invalid,
TR.wipe_code__diff_from_pin,
button=TR.buttons__try_again,
)
@ -1326,7 +1318,7 @@ async def confirm_set_new_pin(
(True, description + "\n\n"),
information,
),
verb=TR.tr("buttons__turn_on"),
verb=TR.buttons__turn_on,
)
),
br_type,

@ -76,13 +76,13 @@ async def confirm_fido(
async def confirm_fido_reset() -> bool:
import trezortranslate as TR
from trezortranslate import TR
confirm = RustLayout(
trezorui2.confirm_action(
title=TR.tr("fido__title_reset"),
action=TR.tr("fido__erase_credentials"),
description=TR.tr("words__really_wanna"),
title=TR.fido__title_reset,
action=TR.fido__erase_credentials,
description=TR.words__really_wanna,
reverse=True,
)
)

@ -120,12 +120,12 @@ class Busyscreen(HomescreenBase):
RENDER_INDICATOR = storage_cache.BUSYSCREEN_ON
def __init__(self, delay_ms: int) -> None:
import trezortranslate as TR
from trezortranslate import TR
skip = storage_cache.homescreen_shown is self.RENDER_INDICATOR
super().__init__(
layout=trezorui2.show_progress_coinjoin(
title=TR.tr("coinjoin__waiting_for_others"),
title=TR.coinjoin__waiting_for_others,
indeterminate=True,
time_ms=delay_ms,
skip_first_paint=skip,

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor import ui
@ -36,7 +36,7 @@ def progress(
description: str | None = None,
indeterminate: bool = False,
) -> ProgressLayout:
message = message or TR.tr("progress__please_wait") # def_arg
message = message or TR.progress__please_wait # def_arg
return RustProgress(
layout=trezorui2.show_progress(
title=message.upper(),
@ -61,12 +61,12 @@ def pin_progress(message: str, description: str) -> ProgressLayout:
def monero_keyimage_sync_progress() -> ProgressLayout:
return progress("", TR.tr("progress__syncing"))
return progress("", TR.progress__syncing)
def monero_live_refresh_progress() -> ProgressLayout:
return progress("", TR.tr("progress__refreshing"), indeterminate=True)
return progress("", TR.progress__refreshing, indeterminate=True)
def monero_transaction_progress_inner() -> ProgressLayout:
return progress("", TR.tr("progress__signing_transaction"))
return progress("", TR.progress__signing_transaction)

@ -1,6 +1,6 @@
from typing import Callable, Iterable
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor.enums import ButtonRequestType
from trezor.wire.context import wait as ctx_wait
@ -33,9 +33,7 @@ async def request_word_count(dry_run: bool) -> int:
async def request_word(word_index: int, word_count: int, is_slip39: bool) -> str:
prompt = TR.tr("recovery__type_word_x_of_y_template").format(
word_index + 1, word_count
)
prompt = TR.recovery__type_word_x_of_y_template.format(word_index + 1, word_count)
if is_slip39:
keyboard = RustLayout(trezorui2.request_slip39(prompt=prompt))
else:
@ -88,10 +86,10 @@ async def show_group_share_success(share_index: int, group_index: int) -> None:
RustLayout(
trezorui2.show_group_share_success(
lines=[
TR.tr("recovery__you_have_entered"),
TR.tr("recovery__share_num_template").format(share_index + 1),
TR.tr("words__from"),
TR.tr("recovery__group_num_template").format(group_index + 1),
TR.recovery__you_have_entered,
TR.recovery__share_num_template.format(share_index + 1),
TR.words__from,
TR.recovery__group_num_template.format(group_index + 1),
],
)
),
@ -113,7 +111,7 @@ async def continue_recovery(
if show_info:
# Show this just one-time
description = TR.tr("recovery__only_2_to_three_words")
description = TR.recovery__only_2_to_three_words
else:
description = subtext or ""
@ -143,7 +141,7 @@ async def show_recovery_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await raise_if_not_confirmed(
interact(
RustLayout(

@ -1,6 +1,6 @@
from typing import TYPE_CHECKING
import trezortranslate as TR
from trezortranslate import TR
import trezorui2
from trezor.enums import ButtonRequestType
from trezor.wire import ActionCancelled
@ -48,11 +48,11 @@ async def show_share_words(
group_index: int | None = None,
) -> None:
if share_index is None:
title = TR.tr("reset__recovery_seed_title")
title = TR.reset__recovery_seed_title
elif group_index is None:
title = TR.tr("reset__recovery_share_title_template").format(share_index + 1)
title = TR.reset__recovery_share_title_template.format(share_index + 1)
else:
title = TR.tr("reset__group_share_title_template").format(
title = TR.reset__group_share_title_template.format(
group_index + 1, share_index + 1
)
@ -80,11 +80,11 @@ async def select_word(
group_index: int | None = None,
) -> str:
if share_index is None:
title: str = TR.tr("reset__check_seed_title")
title: str = TR.reset__check_seed_title
elif group_index is None:
title = TR.tr("reset__check_share_title_template").format(share_index + 1)
title = TR.reset__check_share_title_template.format(share_index + 1)
else:
title = TR.tr("reset__check_group_share_title_template").format(
title = TR.reset__check_group_share_title_template.format(
group_index + 1, share_index + 1
)
@ -99,7 +99,7 @@ async def select_word(
RustLayout(
trezorui2.select_word(
title=title,
description=TR.tr("reset__select_word_x_of_y_template").format(
description=TR.reset__select_word_x_of_y_template.format(
checked_index + 1, count
),
words=(words[0], words[1], words[2]),
@ -119,23 +119,23 @@ async def slip39_show_checklist(step: int, backup_type: BackupType) -> None:
items = (
(
TR.tr("reset__slip39_checklist_set_num_shares"),
TR.tr("reset__slip39_checklist_set_threshold"),
TR.tr("reset__slip39_checklist_write_down_recovery"),
TR.reset__slip39_checklist_set_num_shares,
TR.reset__slip39_checklist_set_threshold,
TR.reset__slip39_checklist_write_down_recovery,
)
if backup_type == BackupType.Slip39_Basic
else (
TR.tr("reset__slip39_checklist_set_num_groups"),
TR.tr("reset__slip39_checklist_set_num_shares"),
TR.tr("reset__slip39_checklist_set_sizes_longer"),
TR.reset__slip39_checklist_set_num_groups,
TR.reset__slip39_checklist_set_num_shares,
TR.reset__slip39_checklist_set_sizes_longer,
)
)
result = await interact(
RustLayout(
trezorui2.show_checklist(
title=TR.tr("reset__slip39_checklist_title"),
button=TR.tr("buttons__continue"),
title=TR.reset__slip39_checklist_title,
button=TR.buttons__continue,
active=step,
items=items,
)
@ -188,7 +188,7 @@ async def _prompt_number(
trezorui2.show_simple(
title=None,
description=info(value),
button=TR.tr("buttons__ok_i_understand"),
button=TR.buttons__ok_i_understand,
)
)
)
@ -207,41 +207,41 @@ async def slip39_prompt_threshold(
def description(count: int) -> str:
if group_id is None:
if count == 1:
return TR.tr("reset__you_need_one_share")
return TR.reset__you_need_one_share
elif count == max_count:
return TR.tr("reset__need_all_share_template").format(count)
return TR.reset__need_all_share_template.format(count)
else:
return TR.tr("reset__need_any_share_template").format(count)
return TR.reset__need_any_share_template.format(count)
else:
return TR.tr("reset__num_shares_for_group_template").format(group_id + 1)
return TR.reset__num_shares_for_group_template.format(group_id + 1)
def info(count: int) -> str:
# TODO: this is madness...
text = TR.tr("reset__the_threshold_sets_the_number_of_shares")
text = TR.reset__the_threshold_sets_the_number_of_shares
if group_id is None:
text += TR.tr("reset__needed_to_recover_your_wallet")
text += TR.tr("reset__set_it_to_count_template").format(count)
text += TR.reset__needed_to_recover_your_wallet
text += TR.reset__set_it_to_count_template.format(count)
if num_of_shares == 1:
text += TR.tr("reset__one_share")
text += TR.reset__one_share
elif num_of_shares == count:
text += TR.tr("reset__all_x_of_y_template").format(count, num_of_shares)
text += TR.reset__all_x_of_y_template.format(count, num_of_shares)
else:
text += TR.tr("reset__any_x_of_y_template").format(count, num_of_shares)
text += TR.reset__any_x_of_y_template.format(count, num_of_shares)
text += "."
else:
text += TR.tr("reset__needed_to_form_a_group")
text += TR.tr("reset__set_it_to_count_template").format(count)
text += TR.reset__needed_to_form_a_group
text += TR.reset__set_it_to_count_template.format(count)
if num_of_shares == 1:
text += TR.tr("reset__one_share") + " "
text += TR.reset__one_share + " "
elif num_of_shares == count:
text += TR.tr("reset__all_x_of_y_template").format(count, num_of_shares)
text += TR.reset__all_x_of_y_template.format(count, num_of_shares)
else:
text += TR.tr("reset__any_x_of_y_template").format(count, num_of_shares)
text += " " + TR.tr("reset__to_form_group_template").format(group_id + 1)
text += TR.reset__any_x_of_y_template.format(count, num_of_shares)
text += " " + TR.reset__to_form_group_template.format(group_id + 1)
return text
return await _prompt_number(
TR.tr("reset__title_set_threshold"),
TR.reset__title_set_threshold,
description,
info,
count,
@ -259,21 +259,21 @@ async def slip39_prompt_number_of_shares(group_id: int | None = None) -> int:
def description(i: int):
if group_id is None:
if i == 1:
return TR.tr("reset__only_one_share_will_be_created")
return TR.reset__only_one_share_will_be_created
else:
return TR.tr("reset__num_of_share_holders_template").format(i)
return TR.reset__num_of_share_holders_template.format(i)
else:
return TR.tr("reset__total_number_of_shares_in_group_template").format(
return TR.reset__total_number_of_shares_in_group_template.format(
group_id + 1
)
if group_id is None:
info = TR.tr("reset__num_of_shares_basic_info")
info = TR.reset__num_of_shares_basic_info
else:
info = TR.tr("reset__num_of_shares_advanced_info_template").format(group_id + 1)
info = TR.reset__num_of_shares_advanced_info_template.format(group_id + 1)
return await _prompt_number(
TR.tr("reset__title_set_number_of_shares"),
TR.reset__title_set_number_of_shares,
description,
lambda i: info,
count,
@ -287,11 +287,11 @@ async def slip39_advanced_prompt_number_of_groups() -> int:
count = 5
min_count = 2
max_count = 16
description = TR.tr("reset__group_description")
info = TR.tr("reset__group_info")
description = TR.reset__group_description
info = TR.reset__group_info
return await _prompt_number(
TR.tr("reset__title_set_number_of_groups"),
TR.reset__title_set_number_of_groups,
lambda i: description,
lambda i: info,
count,
@ -305,11 +305,11 @@ async def slip39_advanced_prompt_group_threshold(num_of_groups: int) -> int:
count = num_of_groups // 2 + 1
min_count = 1
max_count = num_of_groups
description = TR.tr("reset__required_number_of_groups")
info = TR.tr("reset__advanced_group_threshold_info")
description = TR.reset__required_number_of_groups
info = TR.reset__advanced_group_threshold_info
return await _prompt_number(
TR.tr("reset__title_set_group_threshold"),
TR.reset__title_set_group_threshold,
lambda i: description,
lambda i: info,
count,
@ -323,8 +323,8 @@ async def show_warning_backup(slip39: bool) -> None:
result = await interact(
RustLayout(
trezorui2.show_info(
title=TR.tr("reset__never_make_digital_copy"),
button=TR.tr("buttons__ok_i_understand"),
title=TR.reset__never_make_digital_copy,
button=TR.buttons__ok_i_understand,
allow_cancel=False,
)
),
@ -340,8 +340,8 @@ async def show_success_backup() -> None:
await show_success(
"success_backup",
TR.tr("reset__use_your_backup"),
TR.tr("reset__your_backup_is_done"),
TR.reset__use_your_backup,
TR.reset__your_backup_is_done,
)
@ -352,7 +352,7 @@ async def show_reset_warning(
button: str | None = None,
br_code: ButtonRequestType = ButtonRequestType.Warning,
) -> None:
button = button or TR.tr("buttons__try_again") # def_arg
button = button or TR.buttons__try_again # def_arg
await raise_if_not_confirmed(
interact(
RustLayout(

@ -1,4 +1,4 @@
import trezortranslate as TR
from trezortranslate import TR
from trezor.enums import FailureType
@ -26,7 +26,7 @@ class DataError(Error):
class ActionCancelled(Error):
def __init__(self, message: str | None = None) -> None:
message = message or TR.tr("errors__cancelled") # def_arg
message = message or TR.errors__cancelled # def_arg
super().__init__(FailureType.ActionCancelled, message)
@ -37,13 +37,13 @@ class PinExpected(Error):
class PinCancelled(Error):
def __init__(self, message: str | None = None) -> None:
message = message or TR.tr("errors__pin_entry_cancelled") # def_arg
message = message or TR.errors__pin_entry_cancelled # def_arg
super().__init__(FailureType.PinCancelled, message)
class PinInvalid(Error):
def __init__(self, message: str | None = None) -> None:
message = message or TR.tr("errors__pin_invalid") # def_arg
message = message or TR.errors__pin_invalid # def_arg
super().__init__(FailureType.PinInvalid, message)
@ -79,7 +79,7 @@ class WipeCodeMismatch(Error):
class InvalidSession(Error):
def __init__(self, message: str | None = None) -> None:
message = message or TR.tr("errors__invalid_session") # def_arg
message = message or TR.errors__invalid_session # def_arg
super().__init__(FailureType.InvalidSession, message)

Loading…
Cancel
Save