8000 [RFC] Rename Translatable to better follow conventions · Issue #38342 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[RFC] Rename Translatable to better follow conventions #38342
Closed
@dborsatto

Description

@dborsatto

Description

The recently-introduced Translation\Translatable class is a fine addition, but in my opinion it's quite oddly named. Specifically, the *able suffix is usually employed for interfaces (for instance Throwable and Stringable built-in in PHP, and HttpKernel\RebootableInterface in Symfony) and occasionally with traits (like with Command\LockableTrait). Especially lately with the push for removing suffixes and prefixes (like *Interface, *Exception and Abstract*) I believe the name Translatable could result in some confusion in whether we are dealing with a class or an interface. I am aware that TranslatableInterface has just been added, but I think that strengthens my point as that seems to be a much more natural way to use "translatable".

The conventional wisdom is to use actual nouns for naming classes (either describing what they are, as in Exception, or what they do, as in Form\FormBuilder), while adjectives are reserved to interfaces as their purpose is to describe a property or behavior that the concrete class is supposed to have. The name Translatable for a class breaks these general assumptions, and from what I can see this would be something that is not used elsewhere in Symfony, therefore making it an odd case that sticks out. I'm aware that there is an argument for nominal adjectives, but in English pretty much any adjective can be turned into a noun yet that's something we (as developers) don't generally do because it kind of goes against the norm.

My proposal would be to rename Symfony\Component\Translation\Translatable in order to follow the conventional wisdom and style used elsewhere in the project, and now would be the time for doing so as it has not yet shipped in a final release. The simplest way to change it would be something along the lines of TranslatableMessage, but of course there can be many alternatives.

Cheers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0