-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Translation] Introduce NonTranslatableMessage
#60935
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
base: 7.4
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a line in the changelog ?
Just out of curiosity, do you have any examples where you have a Translatable message, that shouldn't be translated? Don't get me wrong but to me it really smells. A Translatable object should inherently be translatable. Setting the But maybe some examples would clear things up for me why this path was chosen. Thanks in advance! 🙏🏻 |
Let's just answer this point first @mdeboer, it's the purpose of the
Sure, for instance Maybe the right behavior would be:
but:
I find it simpler to allow |
false
as domain for translatableMessage
false
as domain for translatableMessage
false
as domain for TranslatableMessage
Thanks for your reply @VincentLanglet I understand that in case of EasyAdmin it is easier to allow this change, but imho this is a design flaw in EasyAdmin. Why should the framework bend the rules and accommodate this bad design pattern? Wouldn't something like Rector be of use to refactor EasyAdmin? Or maybe introduce something like an |
07d269e
to
cdd516b
Compare
No, because
And while it could be considered as a design flaw, be aware that
For instance, form labels are translated by default by Symfony, and they allow a false translation domain now, but you could use the same argument to say it shouldn't translate and wait for TranslateMessage in order to produce a translation, or you should pass the label already-translated.
Might be better indeed (cc @nicolas-grekas if you want to re-review since the whole PR changed). |
false
as domain for TranslatableMessage
UntranslatableMessage
UntranslatableMessage
NonTranslatableMessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, looks good to me 👍🏻 Now it is a clear indicator that the message should not be translated and it fixes the original problem.
When working with translation, it's "classic" to have library with the following logic:
Then if the user doesn't want the text to be translated, he cannot.
A useful and simple way would be to support
new TranslatableMessage($text, domain: false)
but as recommended, it might be better to introduce a special class for this, the NonTranslatableMessage (name to be challenged)