mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Reworking to simplified layout for translations
This commit is contained in:
@@ -165,24 +165,12 @@ def get_letter_counts(
|
|||||||
obj = lang["menuOptions"]
|
obj = lang["menuOptions"]
|
||||||
for mod in defs["menuOptions"]:
|
for mod in defs["menuOptions"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
text_list.append(obj[eid]["desc"])
|
text_list.append(obj[eid]["description"])
|
||||||
|
|
||||||
obj = lang["messages"]
|
|
||||||
for mod in defs["messages"]:
|
|
||||||
eid = mod["id"]
|
|
||||||
if eid not in obj:
|
|
||||||
text_list.append(mod["default"])
|
|
||||||
else:
|
|
||||||
text_list.append(obj[eid])
|
|
||||||
|
|
||||||
obj = lang["messagesWarn"]
|
obj = lang["messagesWarn"]
|
||||||
for mod in defs["messagesWarn"]:
|
for mod in defs["messagesWarn"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid], list):
|
text_list.append(obj[eid]["message"])
|
||||||
text_list.append(obj[eid][0])
|
|
||||||
text_list.append(obj[eid][1])
|
|
||||||
else:
|
|
||||||
text_list.append(obj[eid])
|
|
||||||
|
|
||||||
obj = lang["characters"]
|
obj = lang["characters"]
|
||||||
|
|
||||||
@@ -193,25 +181,17 @@ def get_letter_counts(
|
|||||||
obj = lang["menuOptions"]
|
obj = lang["menuOptions"]
|
||||||
for mod in defs["menuOptions"]:
|
for mod in defs["menuOptions"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid]["text2"], list):
|
text_list.append(obj[eid]["displayText"])
|
||||||
text_list.append(obj[eid]["text2"][0])
|
|
||||||
text_list.append(obj[eid]["text2"][1])
|
|
||||||
else:
|
|
||||||
text_list.append(obj[eid]["text2"])
|
|
||||||
|
|
||||||
obj = lang["menuGroups"]
|
obj = lang["menuGroups"]
|
||||||
for mod in defs["menuGroups"]:
|
for mod in defs["menuGroups"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid]["text2"], list):
|
text_list.append(obj[eid]["displayText"])
|
||||||
text_list.append(obj[eid]["text2"][0])
|
|
||||||
text_list.append(obj[eid]["text2"][1])
|
|
||||||
else:
|
|
||||||
text_list.append(obj[eid]["text2"])
|
|
||||||
|
|
||||||
obj = lang["menuGroups"]
|
obj = lang["menuGroups"]
|
||||||
for mod in defs["menuGroups"]:
|
for mod in defs["menuGroups"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
text_list.append(obj[eid]["desc"])
|
text_list.append(obj[eid]["description"])
|
||||||
constants = get_constants(build_version)
|
constants = get_constants(build_version)
|
||||||
for x in constants:
|
for x in constants:
|
||||||
text_list.append(x[1])
|
text_list.append(x[1])
|
||||||
@@ -355,6 +335,7 @@ class FontMapsPerFont:
|
|||||||
|
|
||||||
|
|
||||||
def get_font_map_per_font(text_list: List[str]) -> FontMapsPerFont:
|
def get_font_map_per_font(text_list: List[str]) -> FontMapsPerFont:
|
||||||
|
print(text_list)
|
||||||
pending_sym_set = set(text_list)
|
pending_sym_set = set(text_list)
|
||||||
if len(pending_sym_set) != len(text_list):
|
if len(pending_sym_set) != len(text_list):
|
||||||
raise ValueError("`text_list` contains duplicated symbols")
|
raise ValueError("`text_list` contains duplicated symbols")
|
||||||
@@ -367,7 +348,6 @@ def get_font_map_per_font(text_list: List[str]) -> FontMapsPerFont:
|
|||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Error, too many used symbols for this version (total {total_symbol_count})"
|
f"Error, too many used symbols for this version (total {total_symbol_count})"
|
||||||
)
|
)
|
||||||
|
|
||||||
logging.info(f"Generating fonts for {total_symbol_count} symbols")
|
logging.info(f"Generating fonts for {total_symbol_count} symbols")
|
||||||
|
|
||||||
# Collect font bitmaps by the defined font order:
|
# Collect font bitmaps by the defined font order:
|
||||||
@@ -416,6 +396,12 @@ def get_font_map_per_font(text_list: List[str]) -> FontMapsPerFont:
|
|||||||
|
|
||||||
|
|
||||||
def get_forced_first_symbols() -> List[str]:
|
def get_forced_first_symbols() -> List[str]:
|
||||||
|
"""Get the list of symbols that must always occur at start of small and large fonts
|
||||||
|
Used by firmware for displaying numbers and hex strings
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List[str]: List of single character strings that must be the first N entries in a font table
|
||||||
|
"""
|
||||||
forced_first_symbols = [
|
forced_first_symbols = [
|
||||||
"0",
|
"0",
|
||||||
"1",
|
"1",
|
||||||
@@ -1028,33 +1014,19 @@ def get_translation_strings_and_indices_text(
|
|||||||
str_group_settingdesc.append(
|
str_group_settingdesc.append(
|
||||||
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
||||||
)
|
)
|
||||||
str_table.append(obj[eid]["desc"])
|
str_table.append(obj[eid]["description"])
|
||||||
|
|
||||||
# ----- Reading Message strings
|
# ----- Reading Message strings
|
||||||
|
|
||||||
obj = lang["messages"]
|
|
||||||
|
|
||||||
for mod in defs["messages"]:
|
|
||||||
eid = mod["id"]
|
|
||||||
source_text = ""
|
|
||||||
if "default" in mod:
|
|
||||||
source_text = mod["default"]
|
|
||||||
if eid in obj:
|
|
||||||
source_text = obj[eid]
|
|
||||||
str_group_messages.append(TranslationItem(eid, len(str_table)))
|
|
||||||
str_table.append(source_text)
|
|
||||||
|
|
||||||
obj = lang["messagesWarn"]
|
obj = lang["messagesWarn"]
|
||||||
|
|
||||||
for mod in defs["messagesWarn"]:
|
for mod in defs["messagesWarn"]:
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid], list):
|
source_text = obj[eid]["message"]
|
||||||
if not obj[eid][1]:
|
if "\n" not in source_text:
|
||||||
source_text = obj[eid][0]
|
source_text="\n"+source_text
|
||||||
else:
|
|
||||||
source_text = obj[eid][0] + "\n" + obj[eid][1]
|
|
||||||
else:
|
|
||||||
source_text = "\n" + obj[eid]
|
|
||||||
str_group_messageswarn.append(TranslationItem(eid, len(str_table)))
|
str_group_messageswarn.append(TranslationItem(eid, len(str_table)))
|
||||||
str_table.append(source_text)
|
str_table.append(source_text)
|
||||||
|
|
||||||
@@ -1072,13 +1044,11 @@ def get_translation_strings_and_indices_text(
|
|||||||
|
|
||||||
for index, mod in enumerate(defs["menuOptions"]):
|
for index, mod in enumerate(defs["menuOptions"]):
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid]["text2"], list):
|
|
||||||
if not obj[eid]["text2"][1]:
|
source_text = obj[eid]["displayText"]
|
||||||
source_text = obj[eid]["text2"][0]
|
|
||||||
else:
|
if "\n" not in source_text:
|
||||||
source_text = obj[eid]["text2"][0] + "\n" + obj[eid]["text2"][1]
|
source_text="\n"+source_text
|
||||||
else:
|
|
||||||
source_text = "\n" + obj[eid]["text2"]
|
|
||||||
str_group_settingshortnames.append(
|
str_group_settingshortnames.append(
|
||||||
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
||||||
)
|
)
|
||||||
@@ -1089,13 +1059,10 @@ def get_translation_strings_and_indices_text(
|
|||||||
|
|
||||||
for index, mod in enumerate(defs["menuGroups"]):
|
for index, mod in enumerate(defs["menuGroups"]):
|
||||||
eid = mod["id"]
|
eid = mod["id"]
|
||||||
if isinstance(obj[eid]["text2"], list):
|
source_text = obj[eid]["displayText"]
|
||||||
if not obj[eid]["text2"][1]:
|
|
||||||
source_text = obj[eid]["text2"][0]
|
if "\n" not in source_text:
|
||||||
else:
|
source_text="\n"+source_text
|
||||||
source_text = obj[eid]["text2"][0] + "\n" + obj[eid]["text2"][1]
|
|
||||||
else:
|
|
||||||
source_text = "\n" + obj[eid]["text2"]
|
|
||||||
str_group_settingmenuentries.append(
|
str_group_settingmenuentries.append(
|
||||||
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
||||||
)
|
)
|
||||||
@@ -1109,7 +1076,7 @@ def get_translation_strings_and_indices_text(
|
|||||||
str_group_settingmenuentriesdesc.append(
|
str_group_settingmenuentriesdesc.append(
|
||||||
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
TranslationItem(f"[{index:02d}] {eid}", len(str_table))
|
||||||
)
|
)
|
||||||
str_table.append(obj[eid]["desc"])
|
str_table.append(obj[eid]["description"])
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class RemappedTranslationItem:
|
class RemappedTranslationItem:
|
||||||
@@ -1355,6 +1322,7 @@ def main() -> None:
|
|||||||
compress_font=args.compress_font,
|
compress_font=args.compress_font,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
language_data.font_map.font06
|
||||||
write_language(language_data, out_, compress_font=args.compress_font)
|
write_language(language_data, out_, compress_font=args.compress_font)
|
||||||
else:
|
else:
|
||||||
if args.strings_obj:
|
if args.strings_obj:
|
||||||
|
|||||||
@@ -1,5 +1,36 @@
|
|||||||
{
|
{
|
||||||
"messages": [{
|
"messagesWarn": [{
|
||||||
|
"id": "CJCCalibrationDone",
|
||||||
|
"description": "Confirmation message indicating CJC calibration is complete."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "SettingsResetMessage",
|
||||||
|
"description": "Shown when the settings are reset to factory defaults either by the user or by incompatible firmware changes."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "NoAccelerometerMessage",
|
||||||
|
"description": "No accelerometer could be communicated with. This means that either the device's accelerometer is broken or unknown to IronOS. All motion-based settings are disabled and motion-based features will not work."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "NoPowerDeliveryMessage",
|
||||||
|
"description": "The IC required for USB-PD could not be communicated with. This is an error warning that USB-PD WILL NOT FUNCTION. Generally indicative of either a hardware or software issues."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "LockingKeysString",
|
||||||
|
"description": "Shown when keys are locked"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "UnlockingKeysString",
|
||||||
|
"description": "Shown when keys are unlocked"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "WarningKeysLockedString",
|
||||||
|
"description": "Warning that is shown when input is ignored due to the key lock being on"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "WarningThermalRunaway",
|
||||||
|
"description": "Warning text shown when the software has disabled the heater as a safety precaution as the temperature reading didn't react as expected."
|
||||||
|
}, {
|
||||||
"id": "SettingsCalibrationWarning",
|
"id": "SettingsCalibrationWarning",
|
||||||
"description": "Confirmation message shown before performing an offset calibration. Should warn the user to make sure tip and handle are at the same temperature."
|
"description": "Confirmation message shown before performing an offset calibration. Should warn the user to make sure tip and handle are at the same temperature."
|
||||||
},
|
},
|
||||||
@@ -53,39 +84,6 @@
|
|||||||
"description": "Warning shown if the device may be a clone or counterfeit unit."
|
"description": "Warning shown if the device may be a clone or counterfeit unit."
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"messagesWarn": [{
|
|
||||||
"id": "CJCCalibrationDone",
|
|
||||||
"description": "Confirmation message indicating CJC calibration is complete."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "SettingsResetMessage",
|
|
||||||
"description": "Shown when the settings are reset to factory defaults either by the user or by incompatible firmware changes."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "NoAccelerometerMessage",
|
|
||||||
"description": "No accelerometer could be communicated with. This means that either the device's accelerometer is broken or unknown to IronOS. All motion-based settings are disabled and motion-based features will not work."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "NoPowerDeliveryMessage",
|
|
||||||
"description": "The IC required for USB-PD could not be communicated with. This is an error warning that USB-PD WILL NOT FUNCTION. Generally indicative of either a hardware or software issues."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "LockingKeysString",
|
|
||||||
"description": "Shown when keys are locked"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "UnlockingKeysString",
|
|
||||||
"description": "Shown when keys are unlocked"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "WarningKeysLockedString",
|
|
||||||
"description": "Warning that is shown when input is ignored due to the key lock being on"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "WarningThermalRunaway",
|
|
||||||
"description": "Warning text shown when the software has disabled the heater as a safety precaution as the temperature reading didn't react as expected."
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"characters": [{
|
"characters": [{
|
||||||
"id": "SettingRightChar",
|
"id": "SettingRightChar",
|
||||||
"len": 1,
|
"len": 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user