Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] TranslatableNormalizer before BackedEnumNormalizer#63040

Closed
Seb33300 wants to merge 1 commit into
symfony:7.4from
Seb33300:TranslatableNormalizer
Closed

[Serializer] TranslatableNormalizer before BackedEnumNormalizer#63040
Seb33300 wants to merge 1 commit into
symfony:7.4from
Seb33300:TranslatableNormalizer

Conversation

@Seb33300
Copy link
Copy Markdown
Contributor

@Seb33300 Seb33300 commented Jan 10, 2026

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #63038
License MIT

Reverting TranslatableNormalizer to be called before BackedEnumNormalizer + add the ability to set NORMALIZATION_LOCALE_KEY to false in order to disable translation on purpose (and fallback on BackedEnumNormalizer).

@Seb33300 Seb33300 requested a review from dunglas as a code owner January 10, 2026 15:21
@carsonbot carsonbot added this to the 8.1 milestone Jan 10, 2026
@Seb33300 Seb33300 changed the base branch from 8.1 to 7.4 January 10, 2026 15:22
@Seb33300 Seb33300 force-pushed the TranslatableNormalizer branch from dd09b26 to 079697e Compare January 11, 2026 03:27
@nicolas-grekas nicolas-grekas modified the milestones: 8.1, 7.4 Jan 12, 2026
@symfony symfony deleted a comment from carsonbot Jan 12, 2026
@nicolas-grekas
Copy link
Copy Markdown
Member

Related to #54315 and #54478 for context.

Maybe @soyuka can advise us a bit on this one?

@stof
Copy link
Copy Markdown
Member

stof commented Jan 12, 2026

We cannot change that now. This is a BC break as projects that have backed enums in their response could suddenly get a different response.

Some projects will expect the API to use the machine-readable representation of the BackedEnum (current behavior where the backing value is used) while some other projects might want to use a human-readable translated value (proposed behavior).
However, I would consider the existing behavior to be superior, because the BackedEnumNormalizer can also deserialize enums, while TranslatableNormalizer does not (and so the data would not roundtrip).

So this gets a -1 vote from me. You can still use a custom normalizer for your own enum if you want it to be serialized in a custom way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Serializer] TranslatableNormalizer not working on BackedEnums

4 participants