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:
@@ -24,7 +24,7 @@ class LeaveWish:
|
||||
id: UUID
|
||||
workspace_id: UUID
|
||||
child_id: UUID | None # None = family-wide; set = tied to that child's pools
|
||||
name: str # "Sommar", "Jullov"
|
||||
name: str # "Sommar", "Jullov" — persisted, possibly-translated display text
|
||||
|
||||
# Recurring anchor stored as month/day ints (SQLite-friendly, no custom type).
|
||||
window_start_month: int # 1-12
|
||||
@@ -55,6 +55,16 @@ class LeaveWish:
|
||||
# completely unmodified.
|
||||
window_mode: str = "fixed" # 'fixed' | 'flexible'
|
||||
|
||||
# Provenance of `name`: when a wish is created from a preset (Sommar,
|
||||
# Jullov, Höstlov, ...) this holds the i18n message key that produced the
|
||||
# translated string stored in `name` (e.g. "wishEditor.presetSommar").
|
||||
# Nullable — free-typed names, and every row created before this field
|
||||
# existed, have no key and just show `name` verbatim. Cleared by
|
||||
# `LeaveWishService.update` the moment the user edits `name`, since a
|
||||
# user-typed name is no longer a preset label and must never silently
|
||||
# revert to one.
|
||||
name_message_key: str | None = None
|
||||
|
||||
created_at: datetime | None = None
|
||||
updated_at: datetime | None = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user