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:
Marc Billow committed 2026-08-08 23:44:54 +00:00
1 parent 8ed3d1467f
commit f5e99d71e3
6 files changed
+24 -22

No files matched your search

@@ -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. `setNightLight` -- preserved exactly as they appear in the OCF resource rep.
""" """
import string
from datetime import UTC, datetime from datetime import UTC, datetime
from datetime import time as dt_time 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): 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): if not isinstance(value, str):
return None return None
if label := personal_course_labels(resources).get(value.upper()): return 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
def _table_id(resources, table_href): 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 # 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 # 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 # live only in the table-scoped translation catalog; a code not confirmed by
# the owner or device metadata continue to use the safe unknown-code fallback, # the owner or device metadata falls back to washer_cycle_fallback, which
# via washer_cycle_fallback (personal-course names, then 'Unknown (0xNN)'). # 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. # /washer/vs/0 -- wash temperature, spin speed, rinse cycle count.
@@ -107,7 +107,7 @@
"name": "Ausgabe läuft" "name": "Ausgabe läuft"
}, },
"remote_control": { "remote_control": {
"name": "Smart Control" "name": "Intelligente Steuerung"
} }
}, },
"button": { "button": {
@@ -150,7 +150,7 @@
"motiondirect": "Bewegung direkt", "motiondirect": "Bewegung direkt",
"drycomfort": "Trockenkomfort", "drycomfort": "Trockenkomfort",
"2step": "2-Stufen", "2step": "2-Stufen",
"smart": "Smart", "smart": "Intelligent",
"nano": "WindFree", "nano": "WindFree",
"sleep": "Schlaf", "sleep": "Schlaf",
"dlightcool": "d'light Cool" "dlightcool": "d'light Cool"
@@ -172,7 +172,7 @@
"state": { "state": {
"mid": "Mittel", "mid": "Mittel",
"sleep": "Schlaf", "sleep": "Schlaf",
"smart": "Smart", "smart": "Intelligent",
"max": "Max", "max": "Max",
"windfree": "WindFree" "windfree": "WindFree"
} }
@@ -702,7 +702,7 @@
"edge_lighting_mode": { "edge_lighting_mode": {
"name": "Randbeleuchtungsmodus", "name": "Randbeleuchtungsmodus",
"state": { "state": {
"smart": "Smart", "smart": "Intelligent",
"high": "Hoch", "high": "Hoch",
"low": "Niedrig" "low": "Niedrig"
} }
@@ -718,7 +718,7 @@
"indicator_light_mode": { "indicator_light_mode": {
"name": "Kontrollleuchtenmodus", "name": "Kontrollleuchtenmodus",
"state": { "state": {
"smart": "Smart", "smart": "Intelligent",
"high": "Hoch", "high": "Hoch",
"low": "Niedrig" "low": "Niedrig"
} }
@@ -632,7 +632,7 @@
"60": "Self Clean+", "60": "Self Clean+",
"65": "Bonte was", "65": "Bonte was",
"66": "Spijkergoed", "66": "Spijkergoed",
"69": "AI Wash", "69": "AI wassen",
"6a": "Wol", "6a": "Wol",
"6b": "Spijkergoed", "6b": "Spijkergoed",
"6c": "Blouses", "6c": "Blouses",
@@ -655,7 +655,7 @@
"7f": "Wol/fijne was", "7f": "Wol/fijne was",
"86": "Diep wassen", "86": "Diep wassen",
"87": "Gedownload", "87": "Gedownload",
"88": "Pet Care", "88": "Huisdierverzorging",
"8f": "Intensief koud", "8f": "Intensief koud",
"96": "Minder microvezels", "96": "Minder microvezels",
"35": "Eco katoen" "35": "Eco katoen"
+4 -3
View File
@@ -95,7 +95,8 @@ class TestCourseHelpers:
} }
assert laundry.personal_course_labels(resources) == {} 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 = { resources = {
"/wm/personalcourse/vs/0": { "/wm/personalcourse/vs/0": {
"x.com.samsung.da.courses": ["F1_0106EC868DEC98B7"], "x.com.samsung.da.courses": ["F1_0106EC868DEC98B7"],
@@ -103,8 +104,8 @@ class TestCourseHelpers:
} }
expected = bytes.fromhex("EC868DEC98B7").decode("utf-8") expected = bytes.fromhex("EC868DEC98B7").decode("utf-8")
assert laundry.washer_cycle_fallback("F1", resources) == expected assert laundry.washer_cycle_fallback("F1", resources) == expected
assert laundry.washer_cycle_fallback("69", resources) == "Unknown (0x69)" assert laundry.washer_cycle_fallback("69", resources) is None
assert laundry.washer_cycle_fallback("6f", resources) == "Unknown (0x6F)" assert laundry.washer_cycle_fallback("6f", resources) is None
assert laundry.washer_cycle_fallback("Normal", resources) is None assert laundry.washer_cycle_fallback("Normal", resources) is None
+2 -2
View File
@@ -237,7 +237,7 @@ def test_confirmed_course_names_are_localized():
}, },
"nl": { "nl": {
"washer": ( "washer": (
"AI Wash", "AI wassen",
"Wol", "Wol",
"Spijkergoed", "Spijkergoed",
"Blouses", "Blouses",
@@ -254,7 +254,7 @@ def test_confirmed_course_names_are_localized():
"Katoen", "Katoen",
"Spoelen + centrifugeren", "Spoelen + centrifugeren",
"Alleen centrifugeren", "Alleen centrifugeren",
"Pet Care", "Huisdierverzorging",
), ),
"dishwasher": ( "dishwasher": (
"Auto", "Auto",