Show preset wish names in the current UI language

Preset wishes were created with `name: t(preset.labelKey)`, so the
translated string was persisted as the wish's name. A wish created while
the UI was Swedish stayed "Jul" in English forever -- the Swedish text
was the data, so no display-layer change could fix it.

Wish names are user-editable free text, so `name` cannot simply be
translated at render time. Migration 007 adds a nullable
`leave_wish.name_message_key` recording where a name came from: preset
wishes store the i18n key alongside the translated literal, and the UI
renders the key when present.

The key is cleared server-side the moment `name` actually changes,
compared against the stored value rather than trusting the caller, so no
client can forget to clear it and silently revert a user's own name to a
preset label.

An unknown key (a stale row, a renamed key) falls back to the stored
literal via an isTranslationKey guard, so a bad key can never crash the
page or leak a raw key to the user. Rows predating this column keep
displaying their stored name.

_FULL_SCHEMA in db/connection.py is updated in step with the migration.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RXMhc9nT6sNz1SL4j8dznL
This commit is contained in:
2026-09-14 22:32:54 +02:00
parent b03462066e
commit dc4c0a5edd
20 changed files with 668 additions and 17 deletions
+5
View File
@@ -29,6 +29,7 @@ async def create_leave_wish(
workspace_id=payload.workspace_id,
child_id=payload.child_id,
name=payload.name,
name_message_key=payload.name_message_key,
window_start_month=payload.window_start_month,
window_start_day=payload.window_start_day,
window_end_month=payload.window_end_month,
@@ -70,6 +71,7 @@ async def update_leave_wish(
leave_wish_id=leave_wish_id,
child_id=payload.child_id,
name=payload.name,
name_message_key=payload.name_message_key,
window_start_month=payload.window_start_month,
window_start_day=payload.window_start_day,
window_end_month=payload.window_end_month,
@@ -90,6 +92,9 @@ async def update_leave_wish(
and payload.parent_personal_data_uuid is None
),
_clear_goal_override=("goal_override" in fields_set and payload.goal_override is None),
_clear_name_message_key=(
"name_message_key" in fields_set and payload.name_message_key is None
),
)
except ValidationError as exc:
raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc