Skip to content

Commit

Permalink
chore(core): support T3B1 for translation blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik committed Sep 3, 2024
1 parent 4002c93 commit 2cb977e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
10 changes: 8 additions & 2 deletions core/translations/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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")]

Expand Down Expand Up @@ -125,7 +125,13 @@ def _lang_path(self, lang: str) -> Path:
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(
Expand Down
2 changes: 1 addition & 1 deletion core/translations/cs.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion core/translations/de.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion core/translations/es.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion core/translations/fr.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions core/translations/signatures.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down
6 changes: 5 additions & 1 deletion tests/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]:
Expand Down

0 comments on commit 2cb977e

Please sign in to comment.