-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
js-translation.json does not pick up strings in *.phtml files #33245
Comments
Hi @amenk. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
For more details, please, review the Magento Contributor Assistant documentation. Please, add a comment to assign the issue:
🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
As code changes are necessary / it's a developer experience issue, I do not know how to reproduce that by the way. But from looking at the code, the issues is pretty clear. |
i think actually issue knockout not translated text in phtml file. Php translate still work as we expected but not in the case that used syntax ko i18n. I just found that text you mentioned only happen in one place and i don't see core team do that again in other place. Another thing i found start from magento 2.4 i dont see file js-translation.json contain anything text when compare with previous version (2.3.x). File js-translation have contain some texts |
Hi @engcom-Lima. Thank you for working on this issue.
|
Hi @amenk, Since this issue is originally 3 years old and were probably tested on old versions of Magento. So can you please check whether this issue still exists on 2.4-develop instance ? If yes, please provide steps to reproduce on 2.4-develop instance. For checking the issue thoroughly, it is very important that the issue should be reproducible. Then only we’ll be able to find a solution to the issue. |
@engcom-Lima No, this issue is not 3 years old. We tested on 2.3.5 and it seems a general problem. I am pretty sure the issue is still there, as in https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Translation/Model/Js/DataProvider.php#L97 also .phtml files are left out from the string collection I currently don't have the time to reproduce this on 2.4, but I hope it's not getting closed, because if it is not fixed, it will frustrate more developers in the future. Short steps to reproduce would be:
This is not easy to reproduce on the Magento 2.4 Dev instances created by the GitHub bot, as we don't have SSH access there. |
https://devdocs.magento.com/guides/v2.4/frontend-dev-guide/translations/translate_theory.html |
Interesting catch, yeah, so it is having a flaw by design. |
Hi @amenk, I tried to reproduce this issue but did not find any problems in translating ‘foo bar 123’ into any language that I wish. Here is what I did:
Please find the attached screenshot of the same. String is getting translated as expected: Can you please try at your end and let me know if you are still facing this issue or update what you did differently at your end to get this issue ? |
@engcom-Lima you have to translate in file phtml use knockout syntax instead for reproduce. That is correct case author try to mention here
|
Yes, exactly how @mrtuvn clarified: Normal .phtml translation on PHP level with the |
Thank you for the clarification. Verified the issue and issue is reproducible on 2.4-develop branch. I added string Language Translation is working with php tag and with knockout translation with Thanks |
✅ Jira issue https://jira.corp.magento.com/browse/AC-1211 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Lima. Thank you for verifying the issue. |
It appears that this issue affects also the translation of strings in the js section of a phtml file using the 'mage/translate' feature.
|
Follow up of #8508 (comment)
Background
Magento automatically picks up strings which should be supplied for the frontend translation via component via js-translation.json. This misses some strings, leaving hard-to-debug problems with translations to other languages.
Summary (*)
The process of fetching strings for js-translation.json has problems in 2.3.5 - and I am pretty sure it's still a problem in the dev master.
We struggled to translate the string "items" for the knockout component "minicart".
Steps to reproduce (*)
Result: String is not getting translated with knockout js tag. It is displayed as ‘foo bar 123’ only.
Examples (*)
The extraction of the files happens here:
magento2/app/code/Magento/Translation/Model/Js/DataProvider.php
Lines 97 to 102 in 32fda1c
The translatable string "items" is introduced here:
magento2/app/code/Magento/Checkout/view/frontend/templates/cart/minicart.phtml
Line 22 in 32fda1c
But the above extraction method does not count *.phtml files in - so translations like this are lost. (it eventually might still end up in the js-translation.json if the same string is used somewhere else in the theme, so such would cover up this bug)
Proposed solution
Include \Magento\Framework\App\Utility\Files::getPhtmlFiles or something similar in the list of files - but this might have a performance impact.
Or remove the whole automatic string extraction and add a manual list of strings which should be included in js-translation.json - this would make the whole process much simpler and less magic.
--
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
The text was updated successfully, but these errors were encountered: