From 234c065aae1f4d9d2a92b15024d182f7fb0a33e1 Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 2 Sep 2024 10:26:13 +0200 Subject: [PATCH] chore(core): support T3B1 for translation blobs --- core/translations/cli.py | 10 ++++++++-- core/translations/cs.json | 2 +- core/translations/de.json | 2 +- core/translations/es.json | 2 +- core/translations/fr.json | 2 +- core/translations/signatures.json | 6 +++--- tests/translations.py | 6 +++++- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/core/translations/cli.py b/core/translations/cli.py index 067aabb07..20cf7c756 100644 --- a/core/translations/cli.py +++ b/core/translations/cli.py @@ -16,7 +16,7 @@ from trezorlib._internal.translations import VersionTuple HERE = Path(__file__).parent.resolve() LOG = logging.getLogger(__name__) -ALL_MODELS = {models.T2B1, models.T2T1, models.T3T1} +ALL_MODELS = {models.T2B1, models.T2T1, models.T3T1, models.T3B1} PRIVATE_KEYS_DEV = [byte * 32 for byte in (b"\xdd", b"\xde", b"\xdf")] @@ -125,7 +125,13 @@ class TranslationsDir: return self.path / f"{lang}.json" def load_lang(self, lang: str) -> translations.JsonDef: - return json.loads(self._lang_path(lang).read_text()) + json_def = json.loads(self._lang_path(lang).read_text()) + # special-case for T2B1 and T3B1, so that we keep the info in one place instead + # of duplicating it in two entries, risking a desync + if (fonts_safe3 := json_def.get("fonts", {}).get("##Safe3")) is not None: + json_def["fonts"]["T2B1"] = fonts_safe3 + json_def["fonts"]["T3B1"] = fonts_safe3 + return json_def def save_lang(self, lang: str, data: translations.JsonDef) -> None: self._lang_path(lang).write_text( diff --git a/core/translations/cs.json b/core/translations/cs.json index cd55d69be..279180ecd 100644 --- a/core/translations/cs.json +++ b/core/translations/cs.json @@ -1,6 +1,6 @@ { "fonts": { - "T2B1": { + "##Safe3": { "1_FONT_NORMAL": "font_pixeloperator_regular_8_cs.json", "2_FONT_BOLD": "font_pixeloperator_bold_8_cs.json", "3_FONT_MONO": "font_pixeloperatormono_regular_8_cs.json", diff --git a/core/translations/de.json b/core/translations/de.json index c7f969c4b..bb1b01fbd 100644 --- a/core/translations/de.json +++ b/core/translations/de.json @@ -1,6 +1,6 @@ { "fonts": { - "T2B1": { + "##Safe3": { "1_FONT_NORMAL": "font_pixeloperator_regular_8_de.json", "2_FONT_BOLD": "font_pixeloperator_bold_8_de.json", "3_FONT_MONO": "font_pixeloperatormono_regular_8_de.json", diff --git a/core/translations/es.json b/core/translations/es.json index 9d1ee3db3..fc153845d 100644 --- a/core/translations/es.json +++ b/core/translations/es.json @@ -1,6 +1,6 @@ { "fonts": { - "T2B1": { + "##Safe3": { "1_FONT_NORMAL": "font_pixeloperator_regular_8_es.json", "2_FONT_BOLD": "font_pixeloperator_bold_8_es.json", "3_FONT_MONO": "font_pixeloperatormono_regular_8_es.json", diff --git a/core/translations/fr.json b/core/translations/fr.json index b2626ed36..66bf1dcf5 100644 --- a/core/translations/fr.json +++ b/core/translations/fr.json @@ -1,6 +1,6 @@ { "fonts": { - "T2B1": { + "##Safe3": { "1_FONT_NORMAL": "font_pixeloperator_regular_8_fr.json", "2_FONT_BOLD": "font_pixeloperator_bold_8_fr.json", "3_FONT_MONO": "font_pixeloperatormono_regular_8_fr.json", diff --git a/core/translations/signatures.json b/core/translations/signatures.json index 8461a14be..bb7706ac4 100644 --- a/core/translations/signatures.json +++ b/core/translations/signatures.json @@ -1,8 +1,8 @@ { "current": { - "merkle_root": "0682f8041f5d002800da51d3c3a36351d326b89ddf8fff6c3e70cd1943f3e064", - "datetime": "2024-08-29T14:44:39.968325", - "commit": "c5e520fd1e34182fb19044baa190dbc81fcf5cad" + "merkle_root": "23cd34c69ea6414849d484a7a9cf990f245d4522371fbdad909807d2bd8efe17", + "datetime": "2024-09-03T08:33:15.680225", + "commit": "4002c934c0dff69ded4247bee4c92bc6642dc0ac" }, "history": [ { diff --git a/tests/translations.py b/tests/translations.py index 48e0ca9a3..b411162ae 100644 --- a/tests/translations.py +++ b/tests/translations.py @@ -70,7 +70,11 @@ def set_language(client: Client, lang: str): def get_lang_json(lang: str) -> translations.JsonDef: assert lang in LANGUAGES - return json.loads((TRANSLATIONS / f"{lang}.json").read_text()) + lang_json = json.loads((TRANSLATIONS / f"{lang}.json").read_text()) + if (fonts_safe3 := lang_json.get("fonts", {}).get("##Safe3")) is not None: + lang_json["fonts"]["T2B1"] = fonts_safe3 + lang_json["fonts"]["T3B1"] = fonts_safe3 + return lang_json def _get_all_language_data() -> list[dict[str, str]]: