Address PR #251 review feedback: no invented English fallback text
washer_cycle_fallback no longer wraps an unrecognized code in an 'Unknown (0xNN)' label -- that baked untranslatable English into a component built to be fully translatable. It now only ever surfaces a device-provided personal-course name; an unrecognized standard code displays as its raw value, same as before PR #251. Also translates nl.json's '69'/'88' washer labels left in English (same review), and makes de.json's own 'smart' states consistent with the 'Intelligente Lüftung' translation already used for smartventilation.
This commit is contained in:
@@ -20,7 +20,6 @@ Door-LED keys use NO `x.com.samsung.da.` prefix -- `setBrightness` /
|
||||
`setNightLight` -- preserved exactly as they appear in the OCF resource rep.
|
||||
"""
|
||||
|
||||
import string
|
||||
from datetime import UTC, datetime
|
||||
from datetime import time as dt_time
|
||||
|
||||
@@ -358,14 +357,15 @@ def personal_course_labels(resources, href="/wm/personalcourse/vs/0"):
|
||||
|
||||
|
||||
def washer_cycle_fallback(value, resources):
|
||||
"""Label an untranslated washer course without guessing its meaning."""
|
||||
"""Label a personal washer course from its device-provided name.
|
||||
|
||||
No fallback for an unrecognized standard code -- an invented English
|
||||
label would defeat translation (PR #251 review); the raw code displays
|
||||
instead, same as before this function existed.
|
||||
"""
|
||||
if not isinstance(value, str):
|
||||
return None
|
||||
if label := personal_course_labels(resources).get(value.upper()):
|
||||
return label
|
||||
if len(value) == 2 and all(char in string.hexdigits for char in value):
|
||||
return f"Unknown (0x{value.upper()})"
|
||||
return None
|
||||
return personal_course_labels(resources).get(value.upper())
|
||||
|
||||
|
||||
def _table_id(resources, table_href):
|
||||
|
||||
@@ -54,9 +54,10 @@ from .laundry import (
|
||||
#
|
||||
# The owner of a Korean Table_02 washer confirmed the names for its newer
|
||||
# 69/6A-79/88 course-code family, including Course_69 as AI Wash. Those names
|
||||
# live only in the table-scoped translation catalog; codes not confirmed by
|
||||
# the owner or device metadata continue to use the safe unknown-code fallback,
|
||||
# via washer_cycle_fallback (personal-course names, then 'Unknown (0xNN)').
|
||||
# live only in the table-scoped translation catalog; a code not confirmed by
|
||||
# the owner or device metadata falls back to washer_cycle_fallback, which
|
||||
# surfaces a personal-course name only -- no invented English label for an
|
||||
# unrecognized standard code (PR #251 review).
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# /washer/vs/0 -- wash temperature, spin speed, rinse cycle count.
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
"name": "Ausgabe läuft"
|
||||
},
|
||||
"remote_control": {
|
||||
"name": "Smart Control"
|
||||
"name": "Intelligente Steuerung"
|
||||
}
|
||||
},
|
||||
"button": {
|
||||
@@ -150,7 +150,7 @@
|
||||
"motiondirect": "Bewegung direkt",
|
||||
"drycomfort": "Trockenkomfort",
|
||||
"2step": "2-Stufen",
|
||||
"smart": "Smart",
|
||||
"smart": "Intelligent",
|
||||
"nano": "WindFree",
|
||||
"sleep": "Schlaf",
|
||||
"dlightcool": "d'light Cool"
|
||||
@@ -172,7 +172,7 @@
|
||||
"state": {
|
||||
"mid": "Mittel",
|
||||
"sleep": "Schlaf",
|
||||
"smart": "Smart",
|
||||
"smart": "Intelligent",
|
||||
"max": "Max",
|
||||
"windfree": "WindFree"
|
||||
}
|
||||
@@ -702,7 +702,7 @@
|
||||
"edge_lighting_mode": {
|
||||
"name": "Randbeleuchtungsmodus",
|
||||
"state": {
|
||||
"smart": "Smart",
|
||||
"smart": "Intelligent",
|
||||
"high": "Hoch",
|
||||
"low": "Niedrig"
|
||||
}
|
||||
@@ -718,7 +718,7 @@
|
||||
"indicator_light_mode": {
|
||||
"name": "Kontrollleuchtenmodus",
|
||||
"state": {
|
||||
"smart": "Smart",
|
||||
"smart": "Intelligent",
|
||||
"high": "Hoch",
|
||||
"low": "Niedrig"
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@
|
||||
"60": "Self Clean+",
|
||||
"65": "Bonte was",
|
||||
"66": "Spijkergoed",
|
||||
"69": "AI Wash",
|
||||
"69": "AI wassen",
|
||||
"6a": "Wol",
|
||||
"6b": "Spijkergoed",
|
||||
"6c": "Blouses",
|
||||
@@ -655,7 +655,7 @@
|
||||
"7f": "Wol/fijne was",
|
||||
"86": "Diep wassen",
|
||||
"87": "Gedownload",
|
||||
"88": "Pet Care",
|
||||
"88": "Huisdierverzorging",
|
||||
"8f": "Intensief koud",
|
||||
"96": "Minder microvezels",
|
||||
"35": "Eco katoen"
|
||||
|
||||
@@ -95,7 +95,8 @@ class TestCourseHelpers:
|
||||
}
|
||||
assert laundry.personal_course_labels(resources) == {}
|
||||
|
||||
def test_washer_cycle_fallback_uses_labels_then_safe_unknown_text(self):
|
||||
def test_washer_cycle_fallback_only_labels_personal_courses(self):
|
||||
"""No invented English label for an unrecognized code (PR #251 review)."""
|
||||
resources = {
|
||||
"/wm/personalcourse/vs/0": {
|
||||
"x.com.samsung.da.courses": ["F1_0106EC868DEC98B7"],
|
||||
@@ -103,8 +104,8 @@ class TestCourseHelpers:
|
||||
}
|
||||
expected = bytes.fromhex("EC868DEC98B7").decode("utf-8")
|
||||
assert laundry.washer_cycle_fallback("F1", resources) == expected
|
||||
assert laundry.washer_cycle_fallback("69", resources) == "Unknown (0x69)"
|
||||
assert laundry.washer_cycle_fallback("6f", resources) == "Unknown (0x6F)"
|
||||
assert laundry.washer_cycle_fallback("69", resources) is None
|
||||
assert laundry.washer_cycle_fallback("6f", resources) is None
|
||||
assert laundry.washer_cycle_fallback("Normal", resources) is None
|
||||
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ def test_confirmed_course_names_are_localized():
|
||||
},
|
||||
"nl": {
|
||||
"washer": (
|
||||
"AI Wash",
|
||||
"AI wassen",
|
||||
"Wol",
|
||||
"Spijkergoed",
|
||||
"Blouses",
|
||||
@@ -254,7 +254,7 @@ def test_confirmed_course_names_are_localized():
|
||||
"Katoen",
|
||||
"Spoelen + centrifugeren",
|
||||
"Alleen centrifugeren",
|
||||
"Pet Care",
|
||||
"Huisdierverzorging",
|
||||
),
|
||||
"dishwasher": (
|
||||
"Auto",
|
||||
|
||||
Reference in New Issue
Block a user