diff --git a/src/apps/management/recovery_device.py b/src/apps/management/recovery_device.py index 041795b3..4346931e 100644 --- a/src/apps/management/recovery_device.py +++ b/src/apps/management/recovery_device.py @@ -9,6 +9,7 @@ from trezor.pin import pin_to_int from trezor.ui.keyboard import MnemonicKeyboard from trezor.ui.text import Text from trezor.ui.word_select import WordSelector +from trezor.utils import format_ordinal from apps.common import storage from apps.management.change_pin import request_pin_confirm @@ -71,8 +72,8 @@ async def request_mnemonic(ctx, count: int) -> str: words = [] board = MnemonicKeyboard() - for i in range(0, count): - board.prompt = 'Type %s. word' % (i + 1) + for i in range(count): + board.prompt = 'Type the %s word:' % format_ordinal(i + 1) word = await board words.append(word) diff --git a/src/apps/management/reset_device.py b/src/apps/management/reset_device.py index 5b6ec589..8fb437de 100644 --- a/src/apps/management/reset_device.py +++ b/src/apps/management/reset_device.py @@ -12,7 +12,7 @@ from trezor.ui.confirm import HoldToConfirmDialog from trezor.ui.keyboard import MnemonicKeyboard from trezor.ui.scroll import Scrollpage, animate_swipe, paginate from trezor.ui.text import Text -from trezor.utils import chunks +from trezor.utils import chunks, format_ordinal from apps.common import storage from apps.common.confirm import require_confirm @@ -178,9 +178,9 @@ async def show_mnemonic_page(page: int, page_count: int, pages: list): async def check_mnemonic(ctx, mnemonic: str) -> bool: words = mnemonic.split() index = random.uniform(len(words) // 2) # first half - result = await MnemonicKeyboard('Type %s. word' % (index + 1)) + result = await MnemonicKeyboard('Type the %s word:' % format_ordinal(index + 1)) if result != words[index]: return False index = len(words) // 2 + random.uniform(len(words) // 2) # second half - result = await MnemonicKeyboard('Type %s. word' % (index + 1)) + result = await MnemonicKeyboard('Type the %s word:' % format_ordinal(index + 1)) return result == words[index] diff --git a/src/trezor/utils.py b/src/trezor/utils.py index cea7521d..faeb4922 100644 --- a/src/trezor/utils.py +++ b/src/trezor/utils.py @@ -34,3 +34,7 @@ def format_amount(amount, decimals): if amount.endswith('.'): amount = amount[:-1] return amount + + +def format_ordinal(number): + return str(number) + {1: 'st', 2: 'nd', 3: 'rd'}.get(4 if 10 <= number % 100 < 20 else number % 10, 'th')