1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

feat(core): Add language_version_matches flag to Features

[no changelog]
This commit is contained in:
Martin Milata 2024-02-22 13:46:07 +01:00
parent f53b945e61
commit a2b53e3c46
2 changed files with 18 additions and 0 deletions

View File

@ -43,6 +43,20 @@ def busy_expiry_ms() -> int:
return expiry_ms if expiry_ms > 0 else 0
def _language_version_matches() -> bool | None:
"""
Whether translation blob version matches firmware version.
Returns None if there is no blob.
"""
from trezor import translations
header = translations.TranslationsHeader.load_from_flash()
if header is None:
return True
return header.version == utils.VERSION
def get_features() -> Features:
import storage.recovery as storage_recovery
from trezor import translations
@ -58,6 +72,7 @@ def get_features() -> Features:
vendor="trezor.io",
fw_vendor=utils.firmware_vendor(),
language=translations.get_language(),
language_version_matches=_language_version_matches(),
major_version=v_major,
minor_version=v_minor,
patch_version=v_patch,

View File

@ -177,15 +177,18 @@ def test_error_invalid_signature(client: Client):
@pytest.mark.parametrize("lang", LANGUAGES)
def test_full_language_change(client: Client, lang: str):
assert client.features.language == "en-US"
assert client.features.language_version_matches is True
# Setting selected language
set_language(client, lang)
assert client.features.language[:2] == lang
assert client.features.language_version_matches is True
_check_ping_screen_texts(client, get_ping_title(lang), get_ping_button(lang))
# Setting the default language via empty data
set_language(client, "en")
assert client.features.language == "en-US"
assert client.features.language_version_matches is True
_check_ping_screen_texts(client, get_ping_title("en"), get_ping_button("en"))