-
-
Notifications
You must be signed in to change notification settings - Fork 773
Expand file tree
/
Copy pathmake_crowdin_comment.py
More file actions
60 lines (44 loc) · 1.58 KB
/
make_crowdin_comment.py
File metadata and controls
60 lines (44 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import json
import sys
RUN_ID, LANGS_JSON = sys.argv[1:]
MAIN = json.loads(LANGS_JSON)
REPORT_URL = f"https://data.trezor.io/dev/firmware/ui_report/{RUN_ID}"
CI_RUN_URL = f"https://github.com/trezor/trezor-firmware/actions/runs/{RUN_ID}"
MODELS_INFO = [
{"id": "T2T1", "name": "Trezor Model T", "layout": "Bolt"},
{"id": "T3B1", "name": "Trezor Safe 3", "layout": "Caesar"},
{"id": "T3T1", "name": "Trezor Safe 5", "layout": "Delizia"},
{"id": "T3W1", "name": "Trezor Safe 7", "layout": "Eckhart"},
]
LANG_NAMES = {
"cs": "Czech",
"de": "German",
"en": "English",
"es": "Spanish",
"fr": "French",
"pt": "Portuguese",
}
def display_lang(code: str) -> str:
return LANG_NAMES.get(code, code) # fallback to the code if unknown
def main():
# a special marker for finding this comment (via CI)
print("<!-- ui-comment-Crowdin -->")
for lang in MAIN:
print_table(lang)
def format_table_row(cells: list[str]) -> str:
"""Format a list of cells as a markdown table row with proper delimiters."""
return "| " + " | ".join(cells) + " |"
def print_table(lang):
print(f"\n# `{display_lang(lang)}`\n")
header = ["layout", "context tests"]
print(format_table_row(header))
print(format_table_row(["---"] * len(header)))
for model in MODELS_INFO:
test_prefix = f"{REPORT_URL}/{model['id']}-{lang}-core_context_tests"
row = [
f"{model['layout']} / {model['name']}",
f"[UI flows]({test_prefix}-index.html)",
]
print(format_table_row(row))
if __name__ == "__main__":
main()