Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Translation] Handle the translation of empty strings#48833
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
carsonbot commentedDec 31, 2022
Hey! I think@rvanlaak has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
maxbeckers commentedJan 10, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
i can't reproduce the problem. When I translate Tried with a clean symfony 5.4 and 6.1 environment. UPDATE |
nicolas-grekas commentedJan 11, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Why don't you use this code instead? $someCondition ?newTranslatableMessage($someObject->someMethod()) :'' It would make more sense to me. Why wrap the empty string in a translatable when it's not translatable content? |
javiereguiluz commentedJan 17, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Looking at Twig Bridge symfony/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php Lines 99 to 122 in1f7bc10
The behavior is different: (1) If we pass a string:
(2) It we pass a
That's why we don't get a "missing translation" warning when doing Would you agree to update |
javiereguiluz commentedJan 19, 2023
I've changed the proposed solution completely. If you can, please review it again. Thanks. |
fbcc902 tof195579Comparenicolas-grekas commentedFeb 23, 2023
Thank you@javiereguiluz. |
In some apps, you might use an expression as the value of some
TranslatableMessageobject. The result of this expression can result in using an empty string as the value of the that object:The issue is that Symfony will report that empty string in the list of "missing translations" (like in the first row of this image):
I think this is a bug and an empty string should just be output "as is" without reporting it as missing.
What do you think? Is this truly a bug? Would it be a new feature for 6.3? The current behavior is correct and we should close without merging? Thanks.