Skip to content

Add Fallback from LocalizedEnumTextAttribute to EnumTextAttribute #20

@dparvin

Description

@dparvin

✨ Feature Request: Fallback from LocalizedEnumTextAttribute → EnumTextAttribute


Overview

Provide a graceful fallback so that when a localized string is not found, the value from an accompanying
EnumTextAttribute is used instead.
This enables incremental migration from static enum labels to fully‑localized strings without breaking the UI.


Proposed Flow

  1. Localized string found → return it.
  2. Localized string missing
    • Debug mode ON → return a diagnostic placeholder
      [[Namespace.ResourceKey]]
    • Debug mode OFF
      • If the enum field has an EnumTextAttribute, return its Text.
      • Otherwise fall back to the raw enum name.
┌───────────┐
│  Exists?  │── Yes ──► return localized
└────┬──────┘
     No
     │
     ▼
┌───────────┐  debug?
│ Debug ON? │── Yes ──► [[ResourcePath::Key]]
└────┬──────┘
     No
     │
     ▼
┌────────────────────────────┐
│ EnumTextAttribute present? │── Yes ──► return EnumText.Text
└────┬───────────────────────┘
     No
     │
     ▼
return enum name

Benefits

  • Incremental migration – keep existing EnumText values until resource strings are ready.
  • No UI regressions – end‑users never see raw resource keys.
  • Debug visibility – missing keys stand out in debug builds.
  • Easy cleanup – once all keys are localized, remove obsolete EnumText attributes.

Implementation Notes

  • Logic can live inside LocalizedEnumTextAttribute.GetLocalizedText() or a helper like Support.GetEnumDisplayText(...).
  • Throw ArgumentException on ResourceUsage.None (consistent with other helpers).
  • Add comprehensive unit tests covering:
    • localized found
    • debug placeholder
    • EnumText fallback
    • final enum‑name fallback.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions