mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Format
This commit is contained in:
@@ -221,7 +221,6 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
|
|||||||
msg = obj[eid]["description"]
|
msg = obj[eid]["description"]
|
||||||
big_font_messages.append(msg)
|
big_font_messages.append(msg)
|
||||||
|
|
||||||
|
|
||||||
obj = lang["menuGroups"]
|
obj = lang["menuGroups"]
|
||||||
for mod in defs["menuGroups"]:
|
for mod in defs["menuGroups"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
@@ -237,7 +236,6 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
|
|||||||
msg = obj[eid]["description"]
|
msg = obj[eid]["description"]
|
||||||
big_font_messages.append(msg)
|
big_font_messages.append(msg)
|
||||||
|
|
||||||
|
|
||||||
constants = get_constants()
|
constants = get_constants()
|
||||||
for x in constants:
|
for x in constants:
|
||||||
if x[0].startswith("Small"):
|
if x[0].startswith("Small"):
|
||||||
@@ -245,7 +243,6 @@ def get_letter_counts(defs: dict, lang: dict, build_version: str) -> Dict:
|
|||||||
else:
|
else:
|
||||||
big_font_messages.append(x[1])
|
big_font_messages.append(x[1])
|
||||||
|
|
||||||
|
|
||||||
small_font_messages.extend(get_debug_menu())
|
small_font_messages.extend(get_debug_menu())
|
||||||
small_font_messages.extend(get_accel_names_list())
|
small_font_messages.extend(get_accel_names_list())
|
||||||
small_font_messages.extend(get_power_source_list())
|
small_font_messages.extend(get_power_source_list())
|
||||||
@@ -551,7 +548,7 @@ def get_forced_first_symbols() -> List[str]:
|
|||||||
"f",
|
"f",
|
||||||
" ", # We lock these to ease printing functions; and they are always included due to constants
|
" ", # We lock these to ease printing functions; and they are always included due to constants
|
||||||
"-",
|
"-",
|
||||||
"+"
|
"+",
|
||||||
]
|
]
|
||||||
return forced_first_symbols
|
return forced_first_symbols
|
||||||
|
|
||||||
@@ -718,9 +715,8 @@ def prepare_languages(
|
|||||||
font_data,
|
font_data,
|
||||||
)
|
)
|
||||||
|
|
||||||
def render_font_block( data: LanguageData,
|
|
||||||
f: TextIO,
|
def render_font_block(data: LanguageData, f: TextIO, compress_font: bool = False):
|
||||||
compress_font: bool = False):
|
|
||||||
font_map = data.font_map
|
font_map = data.font_map
|
||||||
|
|
||||||
small_font_symbol_conversion_table = build_symbol_conversion_map(
|
small_font_symbol_conversion_table = build_symbol_conversion_map(
|
||||||
@@ -782,6 +778,7 @@ def render_font_block( data: LanguageData,
|
|||||||
"};\n"
|
"};\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def write_language(
|
def write_language(
|
||||||
data: LanguageData,
|
data: LanguageData,
|
||||||
f: TextIO,
|
f: TextIO,
|
||||||
@@ -875,8 +872,6 @@ def write_languages(
|
|||||||
compress_font: bool = False,
|
compress_font: bool = False,
|
||||||
) -> None:
|
) -> None:
|
||||||
defs = data.defs
|
defs = data.defs
|
||||||
build_version = data.build_version
|
|
||||||
font_map = data.font_map
|
|
||||||
|
|
||||||
small_font_symbol_conversion_table = build_symbol_conversion_map(
|
small_font_symbol_conversion_table = build_symbol_conversion_map(
|
||||||
data.small_text_symbols
|
data.small_text_symbols
|
||||||
@@ -885,7 +880,6 @@ def write_languages(
|
|||||||
data.large_text_symbols
|
data.large_text_symbols
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
language_codes: List[str] = [lang["languageCode"] for lang in data.langs]
|
language_codes: List[str] = [lang["languageCode"] for lang in data.langs]
|
||||||
logging.info(f"Generating block for {language_codes}")
|
logging.info(f"Generating block for {language_codes}")
|
||||||
|
|
||||||
@@ -901,7 +895,6 @@ def write_languages(
|
|||||||
|
|
||||||
f.write(f"\n// ---- {lang_names} ----\n\n")
|
f.write(f"\n// ---- {lang_names} ----\n\n")
|
||||||
|
|
||||||
|
|
||||||
translation_common_text = get_translation_common_text(
|
translation_common_text = get_translation_common_text(
|
||||||
small_font_symbol_conversion_table, large_font_symbol_conversion_table
|
small_font_symbol_conversion_table, large_font_symbol_conversion_table
|
||||||
)
|
)
|
||||||
@@ -917,7 +910,11 @@ def write_languages(
|
|||||||
lang_code = lang["languageCode"]
|
lang_code = lang["languageCode"]
|
||||||
translation_strings_and_indices_text = (
|
translation_strings_and_indices_text = (
|
||||||
get_translation_strings_and_indices_text(
|
get_translation_strings_and_indices_text(
|
||||||
lang, defs, small_font_symbol_conversion_table,large_font_symbol_conversion_table, suffix=f"_{lang_code}"
|
lang,
|
||||||
|
defs,
|
||||||
|
small_font_symbol_conversion_table,
|
||||||
|
large_font_symbol_conversion_table,
|
||||||
|
suffix=f"_{lang_code}",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
f.write(translation_strings_and_indices_text)
|
f.write(translation_strings_and_indices_text)
|
||||||
@@ -1068,7 +1065,9 @@ def get_translation_strings_and_indices_text(
|
|||||||
record = TranslatedStringLocation(len(byte_encoded_strings) - 1, 0)
|
record = TranslatedStringLocation(len(byte_encoded_strings) - 1, 0)
|
||||||
translated_string_lookups[translation_id] = record
|
translated_string_lookups[translation_id] = record
|
||||||
|
|
||||||
def encode_string_and_add(message: str, translation_id: str,force_large_text:bool=False):
|
def encode_string_and_add(
|
||||||
|
message: str, translation_id: str, force_large_text: bool = False
|
||||||
|
):
|
||||||
encoded_data: bytes
|
encoded_data: bytes
|
||||||
if force_large_text is False and test_is_small_font(message):
|
if force_large_text is False and test_is_small_font(message):
|
||||||
encoded_data = convert_string_bytes(
|
encoded_data = convert_string_bytes(
|
||||||
@@ -1125,9 +1124,7 @@ def get_translation_strings_and_indices_text(
|
|||||||
translation_strings_text += ' "\\0"\n'
|
translation_strings_text += ' "\\0"\n'
|
||||||
|
|
||||||
# Write a comment of what it is
|
# Write a comment of what it is
|
||||||
translation_strings_text += (
|
translation_strings_text += f" // {offset: >4}: {escape(byte_encoded_strings_unencoded_reference[i])}\n"
|
||||||
f" // {offset: >4}: {escape(byte_encoded_strings_unencoded_reference[i])}\n"
|
|
||||||
)
|
|
||||||
# Write the actual data
|
# Write the actual data
|
||||||
translation_strings_text += f' "{bytes_to_escaped(encoded_bytes)}"'
|
translation_strings_text += f' "{bytes_to_escaped(encoded_bytes)}"'
|
||||||
offset += len(encoded_bytes) + 1
|
offset += len(encoded_bytes) + 1
|
||||||
@@ -1154,7 +1151,8 @@ def get_translation_strings_and_indices_text(
|
|||||||
translated_index = translated_string_lookups[key]
|
translated_index = translated_string_lookups[key]
|
||||||
string_index = translated_index.byte_encoded_translation_index
|
string_index = translated_index.byte_encoded_translation_index
|
||||||
start_index = (
|
start_index = (
|
||||||
string_index_commulative_lengths[string_index] + translated_index.str_start_offset
|
string_index_commulative_lengths[string_index]
|
||||||
|
+ translated_index.str_start_offset
|
||||||
)
|
)
|
||||||
|
|
||||||
translation_indices_text += (
|
translation_indices_text += (
|
||||||
@@ -1172,7 +1170,8 @@ def get_translation_strings_and_indices_text(
|
|||||||
translated_index = translated_string_lookups[key]
|
translated_index = translated_string_lookups[key]
|
||||||
string_index = translated_index.byte_encoded_translation_index
|
string_index = translated_index.byte_encoded_translation_index
|
||||||
start_index = (
|
start_index = (
|
||||||
string_index_commulative_lengths[string_index] + translated_index.str_start_offset
|
string_index_commulative_lengths[string_index]
|
||||||
|
+ translated_index.str_start_offset
|
||||||
)
|
)
|
||||||
|
|
||||||
translation_indices_text += (
|
translation_indices_text += (
|
||||||
@@ -1193,7 +1192,8 @@ def get_translation_strings_and_indices_text(
|
|||||||
translated_index = translated_string_lookups[key]
|
translated_index = translated_string_lookups[key]
|
||||||
string_index = translated_index.byte_encoded_translation_index
|
string_index = translated_index.byte_encoded_translation_index
|
||||||
start_index = (
|
start_index = (
|
||||||
string_index_commulative_lengths[string_index] + translated_index.str_start_offset
|
string_index_commulative_lengths[string_index]
|
||||||
|
+ translated_index.str_start_offset
|
||||||
)
|
)
|
||||||
|
|
||||||
output_text += f" /* {record['id'].ljust(max_len)[:max_len]} */ {start_index}, // {escape(raw_string)}\n"
|
output_text += f" /* {record['id'].ljust(max_len)[:max_len]} */ {start_index}, // {escape(raw_string)}\n"
|
||||||
@@ -1201,12 +1201,21 @@ def get_translation_strings_and_indices_text(
|
|||||||
output_text += f" }}, // {name}\n\n"
|
output_text += f" }}, // {name}\n\n"
|
||||||
return output_text
|
return output_text
|
||||||
|
|
||||||
translation_indices_text=write_grouped_indexes(translation_indices_text,"SettingsDescriptions", "menuOptions", "description")
|
translation_indices_text = write_grouped_indexes(
|
||||||
translation_indices_text=write_grouped_indexes(translation_indices_text,"SettingsShortNames", "menuOptions", "displayText")
|
translation_indices_text, "SettingsDescriptions", "menuOptions", "description"
|
||||||
translation_indices_text=write_grouped_indexes(translation_indices_text,
|
)
|
||||||
"SettingsMenuEntriesDescriptions", "menuGroups", "description"
|
translation_indices_text = write_grouped_indexes(
|
||||||
|
translation_indices_text, "SettingsShortNames", "menuOptions", "displayText"
|
||||||
|
)
|
||||||
|
translation_indices_text = write_grouped_indexes(
|
||||||
|
translation_indices_text,
|
||||||
|
"SettingsMenuEntriesDescriptions",
|
||||||
|
"menuGroups",
|
||||||
|
"description",
|
||||||
|
)
|
||||||
|
translation_indices_text = write_grouped_indexes(
|
||||||
|
translation_indices_text, "SettingsMenuEntries", "menuGroups", "displayText"
|
||||||
)
|
)
|
||||||
translation_indices_text=write_grouped_indexes(translation_indices_text,"SettingsMenuEntries", "menuGroups", "displayText")
|
|
||||||
|
|
||||||
translation_indices_text += " }, // .indices\n\n"
|
translation_indices_text += " }, // .indices\n\n"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user