Skip to content

[Issue] Fix #11175 - i18n:collect-phrases -m can't find many important Magento phrases - added parsing of the attr translations via $t('Text') #31873

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

Closed
4 tasks
m2-assistant bot opened this issue Jan 28, 2021 · 3 comments · Fixed by #31804
Assignees
Labels
Component: Setup Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.

Comments

@m2-assistant
Copy link

m2-assistant bot commented Jan 28, 2021

This issue is automatically created based on existing pull request: #31804: Fix #11175 - i18n:collect-phrases -m can't find many important Magento phrases - added parsing of the attr translations via $t('Text')


Description (*)

According to the official Magento 2 documentations, there is a way to translate HTML attributes, but this is not covered as well. Here is a text from the documentation:

When a string is added as an attribute of an HTML element:

<input type="text" data-bind="attr: {placeholder: $t('First Name')}" />

Documentation - Strings added in UI component templates

This was of translating attributes does not seem to be used in the Magento 2 itself (if my search is correct). Though,
it is officially documented, is used by some vendors and it can be found in some Q&A on the Internet
(like here - magento.stackexchange.com)

Related Pull Requests

48216f3

Fixed Issues (if relevant)

  1. Fixes i18n:collect-phrases -m can't find many important magento phrases  #11175 - i18n:collect-phrases -m can't find many important magento phrases

Manual testing scenarios (*)

  1. Add the following code to any Magento .html file, for example app/code/Magento/Catalog/view/frontend/web/template/product/addtocart-button.html
<a data-bind="attr: { title: $t('This is \' test \' data for attribute translation with single quotes'), href: '#'} "></a>
<a data-bind="attr: { title: $t('This is test data for attribute translation with a quote after\'\''), href: '#'} "></a>
<a data-bind="attr: { title: $t('This is test data for attribute translation with a quote after\' \' '), href: '#'} "></a>
<input type="text" data-bind="attr: { placeholder: $t('Attribute translation - Placeholder'), title: $t('Attribute translation - Title') }" />
  1. Run the command php bin/magento i18n:collect-phrases app/code/Magento/Catalog/view/frontend/web/template/product/

Expected result: Command output contains phrases in the $t('Text') translations that cat be then used in the i18n files.
i18n output example:

"This is ' test ' data for attribute translation with single quotes","This is ' test ' data for attribute translation with single quotes"
"This is test data for attribute translation with a quote after''","This is test data for attribute translation with a quote after''"
"This is test data for attribute translation with a quote after' ' ","This is test data for attribute translation with a quote after' ' "
"This is "" test "" data with 'href' after translate","This is "" test "" data with 'href' after translate"

Actual result: The above phrases are not present in the output.

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)
@m2-assistant m2-assistant bot added Component: Setup Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Jan 28, 2021
@engcom-Alfa engcom-Alfa added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Jan 28, 2021
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-40664 were created

Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@gabrieldagama
Copy link
Contributor

Hi @m2-assistant[bot]. Thank you for your report.
The issue has been fixed in #31804 by @maksymz in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.3 release.

@magento-engcom-team
Copy link
Contributor

Unfortunately, we are archiving this ticket now as it did not get much attention from both Magento Community and Core developers for an extended period. This is done in an effort to create a quality, community-driven backlog which will allow us to allocate the required attention more easily.

Please feel free to comment or reopen according to the Issue reporting guidelines
the ticket if you are still facing this issue on the latest 2.x-develop branch. Thank you for collaboration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Setup Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
Archived in project
5 participants