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 2, 2024
1 parent e4b1024 commit 205b4a0
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": "6803ea2d1eb1555ae32a5b32689cdf40d7626a8b3717f6ae9418e0948f9da746",
"datetime": "2024-08-27T15:18:26.530958",
"commit": "6ebe850fe24f5ec894328d82eec97aacccb3d3f5"
"merkle_root": "7ff2dd8837b0a5ccd2564dfeaac3cb8523f88017a678fa459d6372be48d512c5",
"datetime": "2024-09-02T08:24:38.651042",
"commit": "f9ad8de137b1b2ae415142ae9a2217b14daf253b"
},
"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 205b4a0

Please sign in to comment.