mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 14:28:07 +00:00
apps: improve language getters/setters
This commit is contained in:
parent
3f657775e9
commit
e73ff1f3c2
@ -96,6 +96,10 @@ def get_label() -> str:
|
||||
return config_get(_LABEL).decode()
|
||||
|
||||
|
||||
def get_language() -> str:
|
||||
return config_get(_LANGUAGE).decode() or _DEFAULT_LANGUAGE
|
||||
|
||||
|
||||
def get_mnemonic() -> str:
|
||||
utils.ensure(is_initialized())
|
||||
utils.ensure(not is_locked())
|
||||
@ -114,6 +118,10 @@ def load_mnemonic(mnemonic: str):
|
||||
config_set(_MNEMONIC, mnemonic.encode())
|
||||
|
||||
|
||||
_ALLOWED_LANGUAGES = ('english')
|
||||
_DEFAULT_LANGUAGE = 'english'
|
||||
|
||||
|
||||
def load_settings(language: str=None,
|
||||
label: str=None,
|
||||
pin: str=None,
|
||||
@ -121,8 +129,11 @@ def load_settings(language: str=None,
|
||||
utils.ensure(is_initialized())
|
||||
utils.ensure(not is_locked())
|
||||
|
||||
if language is not None:
|
||||
config_set(_LANGUAGE, language.encode())
|
||||
if language is not None and language in _ALLOWED_LANGUAGES:
|
||||
if language is _DEFAULT_LANGUAGE:
|
||||
config_set(_LANGUAGE, b'')
|
||||
else:
|
||||
config_set(_LANGUAGE, language.encode())
|
||||
if label is not None:
|
||||
config_set(_LABEL, label.encode())
|
||||
if pin is not None:
|
||||
|
@ -3,6 +3,7 @@ from trezor.utils import unimport
|
||||
from trezor.messages.wire_types import Initialize, GetFeatures, Ping
|
||||
|
||||
|
||||
@unimport
|
||||
async def respond_Features(session_id, msg):
|
||||
from apps.common import storage, coins
|
||||
from trezor.messages.Features import Features
|
||||
@ -18,6 +19,7 @@ async def respond_Features(session_id, msg):
|
||||
|
||||
f.device_id = storage.get_device_id()
|
||||
f.label = storage.get_label()
|
||||
f.language = storage.get_language()
|
||||
f.initialized = storage.is_initialized()
|
||||
f.pin_protection = storage.is_protected_by_pin()
|
||||
f.passphrase_protection = storage.is_protected_by_passphrase()
|
||||
@ -25,6 +27,7 @@ async def respond_Features(session_id, msg):
|
||||
return f
|
||||
|
||||
|
||||
@unimport
|
||||
async def respond_Pong(session_id, msg):
|
||||
from trezor.messages.Success import Success
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user