Skip to content
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

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

Merged
merged 3 commits into from
Feb 18, 2021

Conversation

maksymz
Copy link
Contributor

@maksymz maksymz commented Jan 22, 2021

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)

Resolved issues:

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

… magento phrases - added parsing of the attr translations via `$t('Text')`
@m2-assistant
Copy link

m2-assistant bot commented Jan 22, 2021

Hi @maksymz. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests 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

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@maksymz, could you sign Adobe CLA in the meanwhile?

@ihor-sviziev ihor-sviziev added Award: bug fix Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. and removed Severity: S1 Affects critical data or functionality and forces users to employ a workaround. labels Jan 22, 2021
@maksymz
Copy link
Contributor Author

maksymz commented Jan 22, 2021

@ihor-sviziev Have just signed the Adobe CLA. Should I reopen the Pull Request? Don't know how to re-run the checks

@m2-assistant
Copy link

m2-assistant bot commented Jan 22, 2021

Hi @maksymz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@engcom-Alfa
Copy link
Contributor

engcom-Alfa commented Jan 28, 2021

✔️ QA Passed

Manual testing scenario:

  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/

Before: ✖️ The above phrases are not present in the output.

Screenshot from 2021-01-28 10-55-16

After: ✔️ Command output contains phrases in the $t('Text') translations that cat be then used in the i18n files.

Screenshot from 2021-01-28 11-12-35

Also added a few phrases that were not collected on the mainline.

Run: php bin/magento i18n:collect-phrases app/code/Magento/

The results can be seen in the comparison of the mainline and with changes from PR - diff

@engcom-Alfa engcom-Alfa added the QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) label Jan 28, 2021
@engcom-Alfa
Copy link
Contributor

@magento create issue

@m2-assistant
Copy link

m2-assistant bot commented Feb 18, 2021

Hi @maksymz, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@vertic4l
Copy link

Could this relate to my issue? #33772

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests Award: bug fix Award: test coverage Component: Setup Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Type: Bug Fix
Projects
None yet
7 participants