-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Rename Translatable to better follow conventions #38342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
now there's an interface, i agree describing the implementation makes more sense. But implying the default translatable is a translatable message string, still works for me as well :) grammar-wise it's fine. If it breaks "The conventional wisdom" i think we should rename it yes 👍 |
The original PR used |
Do you think |
@dborsatto I don't think so, I'm just thinking in regards to if the class name is the exact same, making sure to pick the right one (like After my last comment, I also though about |
How about something different like |
@noahlvb I did think about that one as well. The object isn't actually a translation as that is supplied by the translator. The object that needs to be named is the representation of a message and contextual data that will be used to get a translation at some point later on. |
Opened #38424 in anticipation of changes. |
When using for the first time the feature, I also found
I have mixed feelings about Finally, from a user of the framework point of view, I will use this class to get something translated. |
…eMessage (natewiebe13) This PR was submitted for the master branch but it was merged into the 5.x branch instead. Discussion ---------- [Translation] Rename Translatable class to TranslatableMessage | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #38342 | License | MIT | Doc PR | TBD This PR is in anticipation of #38342 passing. We'll need to also update the docs and the blog post here: https://symfony.com/blog/new-in-symfony-5-2-translatable-objects One extra note not discussed in the issue thread is the increase in the class name length shouldn't really be a problem as `t()` is likely to be used more often. Commits ------- 0d4e25f Rename Translatable class to TranslatableMessage
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 instanceThrowable
andStringable
built-in in PHP, andHttpKernel\RebootableInterface
in Symfony) and occasionally with traits (like withCommand\LockableTrait
). Especially lately with the push for removing suffixes and prefixes (like*Interface
,*Exception
andAbstract*
) I believe the nameTranslatable
could result in some confusion in whether we are dealing with a class or an interface. I am aware thatTranslatableInterface
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 inForm\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 nameTranslatable
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 ofTranslatableMessage
, but of course there can be many alternatives.Cheers
The text was updated successfully, but these errors were encountered: