Merge pull request #1487 from Ralim/translations-cleanup

Cleaning up translations a small amount
This commit is contained in:
Ben V. Brown
2022-12-03 19:26:35 +11:00
committed by GitHub
3 changed files with 361 additions and 376 deletions

View File

@@ -989,6 +989,14 @@ NAME_CYRILLIC: Final = "cyrillic"
NAME_CJK: Final = "cjk" NAME_CJK: Final = "cjk"
NAME_GREEK: Final = "greek" 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( def get_font_maps_for_name(
font_name: str, font_name: str,

View File

@@ -356,16 +356,11 @@ class FontMapsPerFont:
sym_lists: Dict[str, List[str]] 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) 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")
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) total_symbol_count = len(text_list)
# \x00 is for NULL termination and \x01 is for newline, so the maximum # \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 # 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]] = {} font12_maps: Dict[str, Dict[str, bytes]] = {}
font06_maps: Dict[str, Dict[str, Optional[bytes]]] = {} font06_maps: Dict[str, Dict[str, Optional[bytes]]] = {}
sym_lists: Dict[str, List[str]] = {} sym_lists: Dict[str, List[str]] = {}
for font in fonts: for font in font_tables.ALL_FONTS:
font12_maps[font] = {} font12_maps[font] = {}
font12_map = font12_maps[font] font12_map = font12_maps[font]
font06_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_lists[font] = []
sym_list = 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: if font == font_tables.NAME_CJK:
is_cjk = True is_cjk = True
else: else:
@@ -422,10 +411,8 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer
sym_list.append(sym) sym_list.append(sym)
pending_sym_set.remove(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: 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) 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( 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]: ) -> 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 font12_maps = font_maps.font12_maps
font06_maps = font_maps.font06_maps font06_maps = font_maps.font06_maps
# Build the full font maps # Build the full font maps
font12_map = {} font12_map = {}
font06_map = {} font06_map = {}
for font in fonts: for font in font_tables.ALL_FONTS:
font12_map.update(font12_maps[font]) font12_map.update(font12_maps[font])
font06_map.update(font06_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 # Iterate over all of the text to build up the symbols & counts
text_list, _ = get_letter_counts(defs, lang, build_version) text_list, _ = get_letter_counts(defs, lang, build_version)
# From the letter counts, need to make a symbol translator & write out the font # From the letter counts, need to make a symbol translator & write out the font
fonts = lang["fonts"]
forced_first_symbols = get_forced_first_symbols() 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 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( return LanguageData(
[lang], defs, build_version, sym_list, sym_lists_by_font, font_map [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() 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 # Build the full font maps
font12_map = {} font12_map = {}
font06_map = {} font06_map = {}
@@ -625,12 +604,11 @@ def prepare_languages(
total_sym_counts: Dict[str, Dict[str, int]] = {} total_sym_counts: Dict[str, Dict[str, int]] = {}
for lang in langs: for lang in langs:
text_list, sym_counts = get_letter_counts(defs, lang, build_version) text_list, sym_counts = get_letter_counts(defs, lang, build_version)
fonts = lang["fonts"]
text_list = forced_first_symbols + [ text_list = forced_first_symbols + [
x for x in text_list if x not in 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) font_maps = get_font_map_per_font(text_list)
for font in fonts: for font in font_tables.ALL_FONTS:
font12_map.update(font_maps.font12_maps[font]) font12_map.update(font_maps.font12_maps[font])
font06_map.update(font_maps.font06_maps[font]) font06_map.update(font_maps.font06_maps[font])
for font, font_sym_list in font_maps.sym_lists.items(): 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]] = {} sym_lists_by_font: Dict[str, List[str]] = {}
combined_sym_list = [] combined_sym_list = []
for font in all_fonts: for font in font_tables.ALL_FONTS:
if font not in total_sym_counts: if font not in total_sym_counts:
continue continue
# swap to Big -> little sort order # swap to Big -> little sort order
@@ -874,6 +852,9 @@ def write_languages(
"const FontSectionDataInfo FontSectionDataInfos[] = {\n" "const FontSectionDataInfo FontSectionDataInfos[] = {\n"
) )
for font, current_sym_list in sym_lists_by_font.items(): 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 current_sym_start = combined_sym_list.index(current_sym_list[0]) + 2
font_uncompressed = bytearray() font_uncompressed = bytearray()
for sym in current_sym_list: for sym in current_sym_list:

View File

@@ -1,345 +1,341 @@
{ {
"languageCode": "EN", "languageCode": "EN",
"languageLocalName": "English", "languageLocalName": "English",
"fonts": [ "tempUnitFahrenheit": true,
"ascii_basic", "messages": {
"latin_extended" "SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!",
], "CJCCalibrating": "calibrating",
"tempUnitFahrenheit": true, "SettingsResetWarning": "Are you sure you want to restore default settings?",
"messages": { "UVLOWarningString": "DC LOW",
"SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", "UndervoltageString": "Undervoltage",
"CJCCalibrating": "calibrating", "InputVoltageString": "Input V: ",
"SettingsResetWarning": "Are you sure you want to restore default settings?", "SleepingSimpleString": "Zzzz",
"UVLOWarningString": "DC LOW", "SleepingAdvancedString": "Sleeping...",
"UndervoltageString": "Undervoltage", "SleepingTipAdvancedString": "Tip:",
"InputVoltageString": "Input V: ", "OffString": "Off",
"SleepingSimpleString": "Zzzz", "DeviceFailedValidationWarning": "Your device is most likely a counterfeit!"
"SleepingAdvancedString": "Sleeping...", },
"SleepingTipAdvancedString": "Tip:", "messagesWarn": {
"OffString": "Off", "CJCCalibrationDone": [
"DeviceFailedValidationWarning": "Your device is most likely a counterfeit!" "Calibration",
}, "done!"
"messagesWarn": { ],
"CJCCalibrationDone": [ "ResetOKMessage": "Reset OK",
"Calibration", "SettingsResetMessage": [
"done!" "Certain settings",
], "were changed!"
"ResetOKMessage": "Reset OK", ],
"SettingsResetMessage": [ "NoAccelerometerMessage": [
"Certain settings", "No accelerometer",
"were changed!" "detected!"
], ],
"NoAccelerometerMessage": [ "NoPowerDeliveryMessage": [
"No accelerometer", "No USB-PD IC",
"detected!" "detected!"
], ],
"NoPowerDeliveryMessage": [ "LockingKeysString": "LOCKED",
"No USB-PD IC", "UnlockingKeysString": "UNLOCKED",
"detected!" "WarningKeysLockedString": "!LOCKED!",
], "WarningThermalRunaway": [
"LockingKeysString": "LOCKED", "Thermal",
"UnlockingKeysString": "UNLOCKED", "Runaway"
"WarningKeysLockedString": "!LOCKED!", ]
"WarningThermalRunaway": [ },
"Thermal", "characters": {
"Runaway" "SettingRightChar": "R",
] "SettingLeftChar": "L",
}, "SettingAutoChar": "A",
"characters": { "SettingOffChar": "O",
"SettingRightChar": "R", "SettingSlowChar": "S",
"SettingLeftChar": "L", "SettingMediumChar": "M",
"SettingAutoChar": "A", "SettingFastChar": "F",
"SettingOffChar": "O", "SettingStartNoneChar": "O",
"SettingSlowChar": "S", "SettingStartSolderingChar": "S",
"SettingMediumChar": "M", "SettingStartSleepChar": "Z",
"SettingFastChar": "F", "SettingStartSleepOffChar": "R",
"SettingStartNoneChar": "O", "SettingSensitivityOff": "O",
"SettingStartSolderingChar": "S", "SettingSensitivityLow": "L",
"SettingStartSleepChar": "Z", "SettingSensitivityMedium": "M",
"SettingStartSleepOffChar": "R", "SettingSensitivityHigh": "H",
"SettingSensitivityOff": "O", "SettingLockDisableChar": "D",
"SettingSensitivityLow": "L", "SettingLockBoostChar": "B",
"SettingSensitivityMedium": "M", "SettingLockFullChar": "F"
"SettingSensitivityHigh": "H", },
"SettingLockDisableChar": "D", "menuGroups": {
"SettingLockBoostChar": "B", "PowerMenu": {
"SettingLockFullChar": "F" "text2": [
}, "Power",
"menuGroups": { "settings"
"PowerMenu": { ],
"text2": [ "desc": "Settings for Power Supply (Batteries, Quick Charge, PD etc)"
"Power", },
"settings" "SolderingMenu": {
], "text2": [
"desc": "" "Soldering",
}, "settings"
"SolderingMenu": { ],
"text2": [ "desc": "Soldering settings, boost modes; how the iron operates"
"Soldering", },
"settings" "PowerSavingMenu": {
], "text2": [
"desc": "" "Sleep",
}, "mode"
"PowerSavingMenu": { ],
"text2": [ "desc": "Sleep modes; methods we use to save power on the device by shutting down"
"Sleep", },
"mode" "UIMenu": {
], "text2": [
"desc": "" "User",
}, "interface"
"UIMenu": { ],
"text2": [ "desc": "User interactions (how it looks, animations, units etc)"
"User", },
"interface" "AdvancedMenu": {
], "text2": [
"desc": "" "Advanced",
}, "settings"
"AdvancedMenu": { ],
"text2": [ "desc": "Advanced or Misc options."
"Advanced", }
"settings" },
], "menuOptions": {
"desc": "" "DCInCutoff": {
} "text2": [
}, "Power",
"menuOptions": { "source"
"DCInCutoff": { ],
"text2": [ "desc": "Set cutoff voltage to prevent battery overdrainage (DC 10V) (S=3.3V per cell, disable PWR limit)"
"Power", },
"source" "MinVolCell": {
], "text2": [
"desc": "Set cutoff voltage to prevent battery overdrainage (DC 10V) (S=3.3V per cell, disable PWR limit)" "Minimum",
}, "voltage"
"MinVolCell": { ],
"text2": [ "desc": "Minimum allowed voltage per battery cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)"
"Minimum", },
"voltage" "QCMaxVoltage": {
], "text2": [
"desc": "Minimum allowed voltage per battery cell (3S: 3 - 3.7V | 4-6S: 2.4 - 3.7V)" "QC",
}, "voltage"
"QCMaxVoltage": { ],
"text2": [ "desc": "Max QC voltage the iron should negotiate for"
"QC", },
"voltage" "PDNegTimeout": {
], "text2": [
"desc": "Max QC voltage the iron should negotiate for" "PD",
}, "timeout"
"PDNegTimeout": { ],
"text2": [ "desc": "PD negotiation timeout in 100ms steps for compatibility with some QC chargers"
"PD", },
"timeout" "BoostTemperature": {
], "text2": [
"desc": "PD negotiation timeout in 100ms steps for compatibility with some QC chargers" "Boost",
}, "temp"
"BoostTemperature": { ],
"text2": [ "desc": "Tip temperature used in \"boost mode\""
"Boost", },
"temp" "AutoStart": {
], "text2": [
"desc": "Tip temperature used in \"boost mode\"" "Start-up",
}, "behavior"
"AutoStart": { ],
"text2": [ "desc": "O=off | S=heat to soldering temp | Z=standby at sleep temp until moved | R=standby without heating until moved"
"Start-up", },
"behavior" "TempChangeShortStep": {
], "text2": [
"desc": "O=off | S=heat to soldering temp | Z=standby at sleep temp until moved | R=standby without heating until moved" "Temp change",
}, "short"
"TempChangeShortStep": { ],
"text2": [ "desc": "Temperature-change-increment on short button press"
"Temp change", },
"short" "TempChangeLongStep": {
], "text2": [
"desc": "Temperature-change-increment on short button press" "Temp change",
}, "long"
"TempChangeLongStep": { ],
"text2": [ "desc": "Temperature-change-increment on long button press"
"Temp change", },
"long" "LockingMode": {
], "text2": [
"desc": "Temperature-change-increment on long button press" "Allow locking",
}, "buttons"
"LockingMode": { ],
"text2": [ "desc": "While soldering, hold down both buttons to toggle locking them (D=disable | B=boost mode only | F=full locking)"
"Allow locking", },
"buttons" "MotionSensitivity": {
], "text2": [
"desc": "While soldering, hold down both buttons to toggle locking them (D=disable | B=boost mode only | F=full locking)" "Motion",
}, "sensitivity"
"MotionSensitivity": { ],
"text2": [ "desc": "0=off | 1=least sensitive | ... | 9=most sensitive"
"Motion", },
"sensitivity" "SleepTemperature": {
], "text2": [
"desc": "0=off | 1=least sensitive | ... | 9=most sensitive" "Sleep",
}, "temp"
"SleepTemperature": { ],
"text2": [ "desc": "Tip temperature while in \"sleep mode\""
"Sleep", },
"temp" "SleepTimeout": {
], "text2": [
"desc": "Tip temperature while in \"sleep mode\"" "Sleep",
}, "timeout"
"SleepTimeout": { ],
"text2": [ "desc": "Interval before \"sleep mode\" starts (s=seconds | m=minutes)"
"Sleep", },
"timeout" "ShutdownTimeout": {
], "text2": [
"desc": "Interval before \"sleep mode\" starts (s=seconds | m=minutes)" "Shutdown",
}, "timeout"
"ShutdownTimeout": { ],
"text2": [ "desc": "Interval before the iron shuts down (m=minutes)"
"Shutdown", },
"timeout" "HallEffSensitivity": {
], "text2": [
"desc": "Interval before the iron shuts down (m=minutes)" "Hall sensor",
}, "sensitivity"
"HallEffSensitivity": { ],
"text2": [ "desc": "Sensitivity to magnets (0=off | 1=least sensitive | ... | 9=most sensitive)"
"Hall sensor", },
"sensitivity" "TemperatureUnit": {
], "text2": [
"desc": "Sensitivity to magnets (0=off | 1=least sensitive | ... | 9=most sensitive)" "Temperature",
}, "unit"
"TemperatureUnit": { ],
"text2": [ "desc": "C=°Celsius | F=°Fahrenheit"
"Temperature", },
"unit" "DisplayRotation": {
], "text2": [
"desc": "C=°Celsius | F=°Fahrenheit" "Display",
}, "orientation"
"DisplayRotation": { ],
"text2": [ "desc": "R=right-handed | L=left-handed | A=automatic"
"Display", },
"orientation" "CooldownBlink": {
], "text2": [
"desc": "R=right-handed | L=left-handed | A=automatic" "Cooldown",
}, "flashing"
"CooldownBlink": { ],
"text2": [ "desc": "Flash temp reading at idle while tip is hot"
"Cooldown", },
"flashing" "ScrollingSpeed": {
], "text2": [
"desc": "Flash temp reading at idle while tip is hot" "Scrolling",
}, "speed"
"ScrollingSpeed": { ],
"text2": [ "desc": "Speed info text scrolls past at (S=slow | F=fast)"
"Scrolling", },
"speed" "ReverseButtonTempChange": {
], "text2": [
"desc": "Speed info text scrolls past at (S=slow | F=fast)" "Swap",
}, "+ - keys"
"ReverseButtonTempChange": { ],
"text2": [ "desc": "Reverse assignment of buttons for temperature adjustment"
"Swap", },
"+ - keys" "AnimSpeed": {
], "text2": [
"desc": "Reverse assignment of buttons for temperature adjustment" "Anim.",
}, "speed"
"AnimSpeed": { ],
"text2": [ "desc": "Pace of icon animations in menu (O=off | S=slow | M=medium | F=fast)"
"Anim.", },
"speed" "AnimLoop": {
], "text2": [
"desc": "Pace of icon animations in menu (O=off | S=slow | M=medium | F=fast)" "Anim.",
}, "loop"
"AnimLoop": { ],
"text2": [ "desc": "Loop icon animations in main menu"
"Anim.", },
"loop" "Brightness": {
], "text2": [
"desc": "Loop icon animations in main menu" "Screen",
}, "brightness"
"Brightness": { ],
"text2": [ "desc": "Adjust the OLED screen brightness"
"Screen", },
"brightness" "ColourInversion": {
], "text2": [
"desc": "Adjust the OLED screen brightness" "Invert",
}, "screen"
"ColourInversion": { ],
"text2": [ "desc": "Invert the OLED screen colors"
"Invert", },
"screen" "LOGOTime": {
], "text2": [
"desc": "Invert the OLED screen colors" "Boot logo",
}, "duration"
"LOGOTime": { ],
"text2": [ "desc": "Set boot logo duration (s=seconds)"
"Boot logo", },
"duration" "AdvancedIdle": {
], "text2": [
"desc": "Set boot logo duration (s=seconds)" "Detailed",
}, "idle screen"
"AdvancedIdle": { ],
"text2": [ "desc": "Display detailed info in a smaller font on idle screen"
"Detailed", },
"idle screen" "AdvancedSoldering": {
], "text2": [
"desc": "Display detailed info in a smaller font on idle screen" "Detailed",
}, "solder screen"
"AdvancedSoldering": { ],
"text2": [ "desc": "Display detailed info in a smaller font on soldering screen"
"Detailed", },
"solder screen" "PowerLimit": {
], "text2": [
"desc": "Display detailed info in a smaller font on soldering screen" "Power",
}, "limit"
"PowerLimit": { ],
"text2": [ "desc": "Maximum power the iron can use (W=watt)"
"Power", },
"limit" "CalibrateCJC": {
], "text2": [
"desc": "Maximum power the iron can use (W=watt)" "Calibrate CJC",
}, "at next boot"
"CalibrateCJC": { ],
"text2": [ "desc": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)"
"Calibrate CJC", },
"at next boot" "VoltageCalibration": {
], "text2": [
"desc": "At next boot tip Cold Junction Compensation will be calibrated (not required if Delta T is < 5°C)" "Calibrate",
}, "input voltage"
"VoltageCalibration": { ],
"text2": [ "desc": "Start VIN calibration (long press to exit)"
"Calibrate", },
"input voltage" "PowerPulsePower": {
], "text2": [
"desc": "Start VIN calibration (long press to exit)" "Power",
}, "pulse"
"PowerPulsePower": { ],
"text2": [ "desc": "Intensity of power of keep-awake-pulse (watt)"
"Power", },
"pulse" "PowerPulseWait": {
], "text2": [
"desc": "Intensity of power of keep-awake-pulse (watt)" "Power pulse",
}, "delay"
"PowerPulseWait": { ],
"text2": [ "desc": "Delay before keep-awake-pulse is triggered (x 2.5s)"
"Power pulse", },
"delay" "PowerPulseDuration": {
], "text2": [
"desc": "Delay before keep-awake-pulse is triggered (x 2.5s)" "Power pulse",
}, "duration"
"PowerPulseDuration": { ],
"text2": [ "desc": "Keep-awake-pulse duration (x 250ms)"
"Power pulse", },
"duration" "SettingsReset": {
], "text2": [
"desc": "Keep-awake-pulse duration (x 250ms)" "Restore default",
}, "settings"
"SettingsReset": { ],
"text2": [ "desc": "Reset all settings to default"
"Restore default", },
"settings" "LanguageSwitch": {
], "text2": [
"desc": "Reset all settings to default" "Language:",
}, " EN English"
"LanguageSwitch": { ],
"text2": [ "desc": "Toggle active language"
"Language:", }
" EN English" }
], }
"desc": ""
}
}
}