Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand USB-PD mode option #1917

Merged
merged 9 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions Translations/make_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ def check_excluded(record):

return False

for category in ("menuOptions", "menuGroups"):
for index, record in enumerate(defs[category]):
for category in ("menuOptions", "menuGroups", "menuValues"):
for _, record in enumerate(defs[category]):
if check_excluded(record):
lang[category][record["id"]]["displayText"] = ""
lang[category][record["id"]]["description"] = ""

for index, record in enumerate(defs["messagesWarn"]):
for _, record in enumerate(defs["messagesWarn"]):
if check_excluded(record):
lang["messagesWarn"][record["id"]]["message"] = ""

Expand Down Expand Up @@ -249,6 +249,15 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
msg = obj[eid]["description"]
big_font_messages.append(msg)

obj = lang["menuValues"]
for mod in defs["menuValues"]:
eid = mod["id"]
msg = obj[eid]["displayText"]
if test_is_small_font(msg):
small_font_messages.append(msg)
else:
big_font_messages.append(msg)

obj = lang["menuGroups"]
for mod in defs["menuGroups"]:
eid = mod["id"]
Expand Down Expand Up @@ -1114,6 +1123,12 @@ def encode_string_and_add(
encode_string_and_add(
lang_data["displayText"], "menuOptions" + record["id"] + "displayText"
)
for index, record in enumerate(defs["menuValues"]):
lang_data = lang["menuValues"][record["id"]]
# Add to translations the menu text and the description
encode_string_and_add(
lang_data["displayText"], "menuValues" + record["id"] + "displayText"
)

for index, record in enumerate(defs["menuGroups"]):
lang_data = lang["menuGroups"][record["id"]]
Expand Down Expand Up @@ -1201,6 +1216,21 @@ def encode_string_and_add(
f" .{record['id']} = {start_index}, // {escape(lang_data)}\n"
)

for _, record in enumerate(defs["menuValues"]):
# Add to translations the menu text and the description
lang_data = lang["menuValues"][record["id"]]
key = "menuValues" + record["id"] + "displayText"
translated_index = translated_string_lookups[key]
string_index = translated_index.byte_encoded_translation_index
start_index = (
string_index_commulative_lengths[string_index]
+ translated_index.str_start_offset
)

translation_indices_text += (
f" .{record['id']} = {start_index}, // {escape(lang_data)}\n"
)

translation_indices_text += "\n"

# Now for the fun ones, where they are nested and ordered
Expand Down Expand Up @@ -1230,6 +1260,7 @@ def write_grouped_indexes(output_text: str, name: str, mainKey: str, subKey: str
translation_indices_text = write_grouped_indexes(
translation_indices_text, "SettingsShortNames", "menuOptions", "displayText"
)

translation_indices_text = write_grouped_indexes(
translation_indices_text,
"SettingsMenuEntriesDescriptions",
Expand Down
Loading
Loading