From 97651f07d7ff54e960ba18d49e3919d68007ed6d Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 3 Dec 2022 18:35:29 +1100 Subject: [PATCH 1/2] Drop font selection toggle requirement --- Translations/font_tables.py | 8 ++++++ Translations/make_translation.py | 45 +++++++++----------------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/Translations/font_tables.py b/Translations/font_tables.py index 94c3b210..a0b64253 100755 --- a/Translations/font_tables.py +++ b/Translations/font_tables.py @@ -989,6 +989,14 @@ NAME_CYRILLIC: Final = "cyrillic" NAME_CJK: Final = "cjk" NAME_GREEK: Final = "greek" +ALL_FONTS = [ + NAME_ASCII_BASIC, + NAME_LATIN_EXTENDED, + NAME_CYRILLIC, + NAME_GREEK, + NAME_CJK, # CJK must come last +] + def get_font_maps_for_name( font_name: str, diff --git a/Translations/make_translation.py b/Translations/make_translation.py index 466679dd..351664ce 100755 --- a/Translations/make_translation.py +++ b/Translations/make_translation.py @@ -356,16 +356,11 @@ class FontMapsPerFont: sym_lists: Dict[str, List[str]] -def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPerFont: +def get_font_map_per_font(text_list: List[str]) -> FontMapsPerFont: pending_sym_set = set(text_list) if len(pending_sym_set) != len(text_list): raise ValueError("`text_list` contains duplicated symbols") - if fonts[0] != font_tables.NAME_ASCII_BASIC: - raise ValueError( - f'First item in `fonts` must be "{font_tables.NAME_ASCII_BASIC}"' - ) - total_symbol_count = len(text_list) # \x00 is for NULL termination and \x01 is for newline, so the maximum # number of symbols allowed is as follow (see also the comments in @@ -381,7 +376,7 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer font12_maps: Dict[str, Dict[str, bytes]] = {} font06_maps: Dict[str, Dict[str, Optional[bytes]]] = {} sym_lists: Dict[str, List[str]] = {} - for font in fonts: + for font in font_tables.ALL_FONTS: font12_maps[font] = {} font12_map = font12_maps[font] font06_maps[font] = {} @@ -389,12 +384,6 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer sym_lists[font] = [] sym_list = sym_lists[font] - if len(pending_sym_set) == 0: - logging.warning( - f"Font {font} not used because all symbols already have font bitmaps" - ) - continue - if font == font_tables.NAME_CJK: is_cjk = True else: @@ -422,10 +411,8 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer sym_list.append(sym) pending_sym_set.remove(sym) - if len(sym_list) == 0: - logging.warning(f"Font {font} not used by any symbols on the list") if len(pending_sym_set) > 0: - raise KeyError(f"Symbols not found in specified fonts: {pending_sym_set}") + raise KeyError(f"Symbols not found in our fonts: {pending_sym_set}") return FontMapsPerFont(font12_maps, font06_maps, sym_lists) @@ -453,16 +440,16 @@ def get_forced_first_symbols() -> List[str]: def get_sym_list_and_font_map( - text_list: List[str], fonts: List[str] + text_list: List[str], ) -> Tuple[List[str], Dict[str, List[str]], FontMap]: - font_maps = get_font_map_per_font(text_list, fonts) + font_maps = get_font_map_per_font(text_list) font12_maps = font_maps.font12_maps font06_maps = font_maps.font06_maps # Build the full font maps font12_map = {} font06_map = {} - for font in fonts: + for font in font_tables.ALL_FONTS: font12_map.update(font12_maps[font]) font06_map.update(font06_maps[font]) @@ -588,7 +575,6 @@ def prepare_language(lang: dict, defs: dict, build_version: str) -> LanguageData # Iterate over all of the text to build up the symbols & counts text_list, _ = get_letter_counts(defs, lang, build_version) # From the letter counts, need to make a symbol translator & write out the font - fonts = lang["fonts"] forced_first_symbols = get_forced_first_symbols() @@ -597,7 +583,7 @@ def prepare_language(lang: dict, defs: dict, build_version: str) -> LanguageData x for x in text_list if x not in forced_first_symbols ] - sym_list, sym_lists_by_font, font_map = get_sym_list_and_font_map(text_list, fonts) + sym_list, sym_lists_by_font, font_map = get_sym_list_and_font_map(text_list) return LanguageData( [lang], defs, build_version, sym_list, sym_lists_by_font, font_map ) @@ -611,13 +597,6 @@ def prepare_languages( forced_first_symbols = get_forced_first_symbols() - all_fonts = [ - font_tables.NAME_ASCII_BASIC, - font_tables.NAME_LATIN_EXTENDED, - font_tables.NAME_CYRILLIC, - font_tables.NAME_CJK, - ] - # Build the full font maps font12_map = {} font06_map = {} @@ -625,12 +604,11 @@ def prepare_languages( total_sym_counts: Dict[str, Dict[str, int]] = {} for lang in langs: text_list, sym_counts = get_letter_counts(defs, lang, build_version) - fonts = lang["fonts"] text_list = forced_first_symbols + [ x for x in text_list if x not in forced_first_symbols ] - font_maps = get_font_map_per_font(text_list, fonts) - for font in fonts: + font_maps = get_font_map_per_font(text_list) + for font in font_tables.ALL_FONTS: font12_map.update(font_maps.font12_maps[font]) font06_map.update(font_maps.font06_maps[font]) for font, font_sym_list in font_maps.sym_lists.items(): @@ -643,7 +621,7 @@ def prepare_languages( sym_lists_by_font: Dict[str, List[str]] = {} combined_sym_list = [] - for font in all_fonts: + for font in font_tables.ALL_FONTS: if font not in total_sym_counts: continue # swap to Big -> little sort order @@ -874,6 +852,9 @@ def write_languages( "const FontSectionDataInfo FontSectionDataInfos[] = {\n" ) for font, current_sym_list in sym_lists_by_font.items(): + print(font, current_sym_list) + if len(current_sym_list) == 0: + continue current_sym_start = combined_sym_list.index(current_sym_list[0]) + 2 font_uncompressed = bytearray() for sym in current_sym_list: From b245899050f6dfcba5f661c1d4cec1699279a1a6 Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 3 Dec 2022 19:22:51 +1100 Subject: [PATCH 2/2] Update EN desc text --- Translations/translation_EN.json | 684 +++++++++++++++---------------- 1 file changed, 340 insertions(+), 344 deletions(-) diff --git a/Translations/translation_EN.json b/Translations/translation_EN.json index 93e7a35e..bd38d1b4 100644 --- a/Translations/translation_EN.json +++ b/Translations/translation_EN.json @@ -1,345 +1,341 @@ { - "languageCode": "EN", - "languageLocalName": "English", - "fonts": [ - "ascii_basic", - "latin_extended" - ], - "tempUnitFahrenheit": true, - "messages": { - "SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", - "CJCCalibrating": "calibrating", - "SettingsResetWarning": "Are you sure you want to restore default settings?", - "UVLOWarningString": "DC LOW", - "UndervoltageString": "Undervoltage", - "InputVoltageString": "Input V: ", - "SleepingSimpleString": "Zzzz", - "SleepingAdvancedString": "Sleeping...", - "SleepingTipAdvancedString": "Tip:", - "OffString": "Off", - "DeviceFailedValidationWarning": "Your device is most likely a counterfeit!" - }, - "messagesWarn": { - "CJCCalibrationDone": [ - "Calibration", - "done!" - ], - "ResetOKMessage": "Reset OK", - "SettingsResetMessage": [ - "Certain settings", - "were changed!" - ], - "NoAccelerometerMessage": [ - "No accelerometer", - "detected!" - ], - "NoPowerDeliveryMessage": [ - "No USB-PD IC", - "detected!" - ], - "LockingKeysString": "LOCKED", - "UnlockingKeysString": "UNLOCKED", - "WarningKeysLockedString": "!LOCKED!", - "WarningThermalRunaway": [ - "Thermal", - "Runaway" - ] - }, - "characters": { - "SettingRightChar": "R", - "SettingLeftChar": "L", - "SettingAutoChar": "A", - "SettingOffChar": "O", - "SettingSlowChar": "S", - "SettingMediumChar": "M", - "SettingFastChar": "F", - "SettingStartNoneChar": "O", - "SettingStartSolderingChar": "S", - "SettingStartSleepChar": "Z", - "SettingStartSleepOffChar": "R", - "SettingSensitivityOff": "O", - "SettingSensitivityLow": "L", - "SettingSensitivityMedium": "M", - "SettingSensitivityHigh": "H", - "SettingLockDisableChar": "D", - "SettingLockBoostChar": "B", - "SettingLockFullChar": "F" - }, - "menuGroups": { - "PowerMenu": { - "text2": [ - "Power", - "settings" - ], - "desc": "" - }, - "SolderingMenu": { - "text2": [ - "Soldering", - "settings" - ], - "desc": "" - }, - "PowerSavingMenu": { - "text2": [ - "Sleep", - "mode" - ], - "desc": "" - }, - "UIMenu": { - "text2": [ - "User", - "interface" - ], - "desc": "" - }, - "AdvancedMenu": { - "text2": [ - "Advanced", - "settings" - ], - "desc": "" - } - }, - "menuOptions": { - "DCInCutoff": { - "text2": [ - "Power", - "source" - ], - "desc": "Set cutoff voltage to prevent battery overdrainage (DC 10V) (S=3.3V per cell, disable PWR limit)" - }, - "MinVolCell": { - "text2": [ - "Minimum", - "voltage" - ], - "desc": "Minimum allowed voltage per battery cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)" - }, - "QCMaxVoltage": { - "text2": [ - "QC", - "voltage" - ], - "desc": "Max QC voltage the iron should negotiate for" - }, - "PDNegTimeout": { - "text2": [ - "PD", - "timeout" - ], - "desc": "PD negotiation timeout in 100ms steps for compatibility with some QC chargers" - }, - "BoostTemperature": { - "text2": [ - "Boost", - "temp" - ], - "desc": "Tip temperature used in \"boost mode\"" - }, - "AutoStart": { - "text2": [ - "Start-up", - "behavior" - ], - "desc": "O=off | S=heat to soldering temp | Z=standby at sleep temp until moved | R=standby without heating until moved" - }, - "TempChangeShortStep": { - "text2": [ - "Temp change", - "short" - ], - "desc": "Temperature-change-increment on short button press" - }, - "TempChangeLongStep": { - "text2": [ - "Temp change", - "long" - ], - "desc": "Temperature-change-increment on long button press" - }, - "LockingMode": { - "text2": [ - "Allow locking", - "buttons" - ], - "desc": "While soldering, hold down both buttons to toggle locking them (D=disable | B=boost mode only | F=full locking)" - }, - "MotionSensitivity": { - "text2": [ - "Motion", - "sensitivity" - ], - "desc": "0=off | 1=least sensitive | ... | 9=most sensitive" - }, - "SleepTemperature": { - "text2": [ - "Sleep", - "temp" - ], - "desc": "Tip temperature while in \"sleep mode\"" - }, - "SleepTimeout": { - "text2": [ - "Sleep", - "timeout" - ], - "desc": "Interval before \"sleep mode\" starts (s=seconds | m=minutes)" - }, - "ShutdownTimeout": { - "text2": [ - "Shutdown", - "timeout" - ], - "desc": "Interval before the iron shuts down (m=minutes)" - }, - "HallEffSensitivity": { - "text2": [ - "Hall sensor", - "sensitivity" - ], - "desc": "Sensitivity to magnets (0=off | 1=least sensitive | ... | 9=most sensitive)" - }, - "TemperatureUnit": { - "text2": [ - "Temperature", - "unit" - ], - "desc": "C=°Celsius | F=°Fahrenheit" - }, - "DisplayRotation": { - "text2": [ - "Display", - "orientation" - ], - "desc": "R=right-handed | L=left-handed | A=automatic" - }, - "CooldownBlink": { - "text2": [ - "Cooldown", - "flashing" - ], - "desc": "Flash temp reading at idle while tip is hot" - }, - "ScrollingSpeed": { - "text2": [ - "Scrolling", - "speed" - ], - "desc": "Speed info text scrolls past at (S=slow | F=fast)" - }, - "ReverseButtonTempChange": { - "text2": [ - "Swap", - "+ - keys" - ], - "desc": "Reverse assignment of buttons for temperature adjustment" - }, - "AnimSpeed": { - "text2": [ - "Anim.", - "speed" - ], - "desc": "Pace of icon animations in menu (O=off | S=slow | M=medium | F=fast)" - }, - "AnimLoop": { - "text2": [ - "Anim.", - "loop" - ], - "desc": "Loop icon animations in main menu" - }, - "Brightness": { - "text2": [ - "Screen", - "brightness" - ], - "desc": "Adjust the OLED screen brightness" - }, - "ColourInversion": { - "text2": [ - "Invert", - "screen" - ], - "desc": "Invert the OLED screen colors" - }, - "LOGOTime": { - "text2": [ - "Boot logo", - "duration" - ], - "desc": "Set boot logo duration (s=seconds)" - }, - "AdvancedIdle": { - "text2": [ - "Detailed", - "idle screen" - ], - "desc": "Display detailed info in a smaller font on idle screen" - }, - "AdvancedSoldering": { - "text2": [ - "Detailed", - "solder screen" - ], - "desc": "Display detailed info in a smaller font on soldering screen" - }, - "PowerLimit": { - "text2": [ - "Power", - "limit" - ], - "desc": "Maximum power the iron can use (W=watt)" - }, - "CalibrateCJC": { - "text2": [ - "Calibrate CJC", - "at next boot" - ], - "desc": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)" - }, - "VoltageCalibration": { - "text2": [ - "Calibrate", - "input voltage" - ], - "desc": "Start VIN calibration (long press to exit)" - }, - "PowerPulsePower": { - "text2": [ - "Power", - "pulse" - ], - "desc": "Intensity of power of keep-awake-pulse (watt)" - }, - "PowerPulseWait": { - "text2": [ - "Power pulse", - "delay" - ], - "desc": "Delay before keep-awake-pulse is triggered (x 2.5s)" - }, - "PowerPulseDuration": { - "text2": [ - "Power pulse", - "duration" - ], - "desc": "Keep-awake-pulse duration (x 250ms)" - }, - "SettingsReset": { - "text2": [ - "Restore default", - "settings" - ], - "desc": "Reset all settings to default" - }, - "LanguageSwitch": { - "text2": [ - "Language:", - " EN English" - ], - "desc": "" - } - } -} + "languageCode": "EN", + "languageLocalName": "English", + "tempUnitFahrenheit": true, + "messages": { + "SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", + "CJCCalibrating": "calibrating", + "SettingsResetWarning": "Are you sure you want to restore default settings?", + "UVLOWarningString": "DC LOW", + "UndervoltageString": "Undervoltage", + "InputVoltageString": "Input V: ", + "SleepingSimpleString": "Zzzz", + "SleepingAdvancedString": "Sleeping...", + "SleepingTipAdvancedString": "Tip:", + "OffString": "Off", + "DeviceFailedValidationWarning": "Your device is most likely a counterfeit!" + }, + "messagesWarn": { + "CJCCalibrationDone": [ + "Calibration", + "done!" + ], + "ResetOKMessage": "Reset OK", + "SettingsResetMessage": [ + "Certain settings", + "were changed!" + ], + "NoAccelerometerMessage": [ + "No accelerometer", + "detected!" + ], + "NoPowerDeliveryMessage": [ + "No USB-PD IC", + "detected!" + ], + "LockingKeysString": "LOCKED", + "UnlockingKeysString": "UNLOCKED", + "WarningKeysLockedString": "!LOCKED!", + "WarningThermalRunaway": [ + "Thermal", + "Runaway" + ] + }, + "characters": { + "SettingRightChar": "R", + "SettingLeftChar": "L", + "SettingAutoChar": "A", + "SettingOffChar": "O", + "SettingSlowChar": "S", + "SettingMediumChar": "M", + "SettingFastChar": "F", + "SettingStartNoneChar": "O", + "SettingStartSolderingChar": "S", + "SettingStartSleepChar": "Z", + "SettingStartSleepOffChar": "R", + "SettingSensitivityOff": "O", + "SettingSensitivityLow": "L", + "SettingSensitivityMedium": "M", + "SettingSensitivityHigh": "H", + "SettingLockDisableChar": "D", + "SettingLockBoostChar": "B", + "SettingLockFullChar": "F" + }, + "menuGroups": { + "PowerMenu": { + "text2": [ + "Power", + "settings" + ], + "desc": "Settings for Power Supply (Batteries, Quick Charge, PD etc)" + }, + "SolderingMenu": { + "text2": [ + "Soldering", + "settings" + ], + "desc": "Soldering settings, boost modes; how the iron operates" + }, + "PowerSavingMenu": { + "text2": [ + "Sleep", + "mode" + ], + "desc": "Sleep modes; methods we use to save power on the device by shutting down" + }, + "UIMenu": { + "text2": [ + "User", + "interface" + ], + "desc": "User interactions (how it looks, animations, units etc)" + }, + "AdvancedMenu": { + "text2": [ + "Advanced", + "settings" + ], + "desc": "Advanced or Misc options." + } + }, + "menuOptions": { + "DCInCutoff": { + "text2": [ + "Power", + "source" + ], + "desc": "Set cutoff voltage to prevent battery overdrainage (DC 10V) (S=3.3V per cell, disable PWR limit)" + }, + "MinVolCell": { + "text2": [ + "Minimum", + "voltage" + ], + "desc": "Minimum allowed voltage per battery cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)" + }, + "QCMaxVoltage": { + "text2": [ + "QC", + "voltage" + ], + "desc": "Max QC voltage the iron should negotiate for" + }, + "PDNegTimeout": { + "text2": [ + "PD", + "timeout" + ], + "desc": "PD negotiation timeout in 100ms steps for compatibility with some QC chargers" + }, + "BoostTemperature": { + "text2": [ + "Boost", + "temp" + ], + "desc": "Tip temperature used in \"boost mode\"" + }, + "AutoStart": { + "text2": [ + "Start-up", + "behavior" + ], + "desc": "O=off | S=heat to soldering temp | Z=standby at sleep temp until moved | R=standby without heating until moved" + }, + "TempChangeShortStep": { + "text2": [ + "Temp change", + "short" + ], + "desc": "Temperature-change-increment on short button press" + }, + "TempChangeLongStep": { + "text2": [ + "Temp change", + "long" + ], + "desc": "Temperature-change-increment on long button press" + }, + "LockingMode": { + "text2": [ + "Allow locking", + "buttons" + ], + "desc": "While soldering, hold down both buttons to toggle locking them (D=disable | B=boost mode only | F=full locking)" + }, + "MotionSensitivity": { + "text2": [ + "Motion", + "sensitivity" + ], + "desc": "0=off | 1=least sensitive | ... | 9=most sensitive" + }, + "SleepTemperature": { + "text2": [ + "Sleep", + "temp" + ], + "desc": "Tip temperature while in \"sleep mode\"" + }, + "SleepTimeout": { + "text2": [ + "Sleep", + "timeout" + ], + "desc": "Interval before \"sleep mode\" starts (s=seconds | m=minutes)" + }, + "ShutdownTimeout": { + "text2": [ + "Shutdown", + "timeout" + ], + "desc": "Interval before the iron shuts down (m=minutes)" + }, + "HallEffSensitivity": { + "text2": [ + "Hall sensor", + "sensitivity" + ], + "desc": "Sensitivity to magnets (0=off | 1=least sensitive | ... | 9=most sensitive)" + }, + "TemperatureUnit": { + "text2": [ + "Temperature", + "unit" + ], + "desc": "C=°Celsius | F=°Fahrenheit" + }, + "DisplayRotation": { + "text2": [ + "Display", + "orientation" + ], + "desc": "R=right-handed | L=left-handed | A=automatic" + }, + "CooldownBlink": { + "text2": [ + "Cooldown", + "flashing" + ], + "desc": "Flash temp reading at idle while tip is hot" + }, + "ScrollingSpeed": { + "text2": [ + "Scrolling", + "speed" + ], + "desc": "Speed info text scrolls past at (S=slow | F=fast)" + }, + "ReverseButtonTempChange": { + "text2": [ + "Swap", + "+ - keys" + ], + "desc": "Reverse assignment of buttons for temperature adjustment" + }, + "AnimSpeed": { + "text2": [ + "Anim.", + "speed" + ], + "desc": "Pace of icon animations in menu (O=off | S=slow | M=medium | F=fast)" + }, + "AnimLoop": { + "text2": [ + "Anim.", + "loop" + ], + "desc": "Loop icon animations in main menu" + }, + "Brightness": { + "text2": [ + "Screen", + "brightness" + ], + "desc": "Adjust the OLED screen brightness" + }, + "ColourInversion": { + "text2": [ + "Invert", + "screen" + ], + "desc": "Invert the OLED screen colors" + }, + "LOGOTime": { + "text2": [ + "Boot logo", + "duration" + ], + "desc": "Set boot logo duration (s=seconds)" + }, + "AdvancedIdle": { + "text2": [ + "Detailed", + "idle screen" + ], + "desc": "Display detailed info in a smaller font on idle screen" + }, + "AdvancedSoldering": { + "text2": [ + "Detailed", + "solder screen" + ], + "desc": "Display detailed info in a smaller font on soldering screen" + }, + "PowerLimit": { + "text2": [ + "Power", + "limit" + ], + "desc": "Maximum power the iron can use (W=watt)" + }, + "CalibrateCJC": { + "text2": [ + "Calibrate CJC", + "at next boot" + ], + "desc": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)" + }, + "VoltageCalibration": { + "text2": [ + "Calibrate", + "input voltage" + ], + "desc": "Start VIN calibration (long press to exit)" + }, + "PowerPulsePower": { + "text2": [ + "Power", + "pulse" + ], + "desc": "Intensity of power of keep-awake-pulse (watt)" + }, + "PowerPulseWait": { + "text2": [ + "Power pulse", + "delay" + ], + "desc": "Delay before keep-awake-pulse is triggered (x 2.5s)" + }, + "PowerPulseDuration": { + "text2": [ + "Power pulse", + "duration" + ], + "desc": "Keep-awake-pulse duration (x 250ms)" + }, + "SettingsReset": { + "text2": [ + "Restore default", + "settings" + ], + "desc": "Reset all settings to default" + }, + "LanguageSwitch": { + "text2": [ + "Language:", + " EN English" + ], + "desc": "Toggle active language" + } + } +} \ No newline at end of file