magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.55k stars 9.32k forks source link

Form validation translations not working #36587

Open adamlavery opened 1 year ago

adamlavery commented 1 year ago

Preconditions and environment

OS 2.4.3-p1

Steps to reproduce

Trying to translate poorly worded form validation messages into proper English i.e.

"Please enter less or equal than %1 symbols.","Please enter maximum %1 characters."
"Please enter more or equal than %1 symbols.","Please enter minimum %1 characters."
"Please enter more or equal than {0} symbols.","Please enter maximum {0} characters."
"Please enter less or equal than {0} symbols.","Please enter minimum {0} characters."

Have created theme\il8n\en_GB.csv to include above corrections to proper English. Other "translations" in the csv file are applying correctly e.g.

"Edit item parameters", "Edit this item"
"Subscribe", "Start Saving"

Expected result

According to the following article, my theme translations should be being used: https://developer.adobe.com/commerce/frontend-core/guide/translations/dictionary/

How the application applies locales When the locale is changed for a store, the application searches and applies translations in the corresponding dictionaries in the following sequence:

  1. Module translations: /i18n/
  2. Translation package: app/i18n/
  3. Theme translations: /i18n/ (iterated through all ancestor themes) /i18n/
  4. The database (translations located in this database take precedence and override translations stored in other locations.)

Actual result

Re-deployed static content (in developer mode so shouldn't need to often do have to anyway) Cleared and flushed cache

Rule validation messages are not translated.

Additional information

Messages come from vendor\magento\module-ui\view\base\web\js\lib\validation\rules.js

Additional steps to reproduce the issue

  1. Add below translations in the files app/design/adminhtml/Magento/backend/i18n/en_US.csv and app/design/frontend/Magento/luma/i18n/en_US.csv:

    "Please enter less or equal than %1 symbols.","Please enter maximum %1 characters."
    "Please enter more or equal than %1 symbols.","Please enter minimum %1 characters."
    "Please enter more or equal than {0} symbols.","Please enter maximum {0} characters."
    "Please enter less or equal than {0} symbols.","Please enter minimum {0} characters."
    "Edit item parameters","Edit item"
    "Subscribe", "Start Saving"
  2. Run the below commands to clear the cache:

    bin/magento c:c
    bin/magento c:f
  3. Refresh the frontend and check the translations, this is translating well: image

  4. Check this path for other translations Admin Panel -> Marketing -> SEO & Search -> Site Map -> Add Sitemap and try to add text greater than 32 characters in the Filename field. New translations is not applied: New-Site-Map-Site-Map-SEO-Search-Marketing-Magento-Admin

  5. But after running bin/magento setup:upgrade translations are working: 2-New-Site-Map-Site-Map-SEO-Search-Marketing-Magento-Admin

Release note

No response

Triage and priority

m2-assistant[bot] commented 1 year ago

Hi @adamlavery. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

adamlavery commented 1 year ago

As we can't do translations on a test instance, not requesting one!

m2-assistant[bot] commented 1 year ago

Hi @engcom-Dash. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:


adamlavery commented 1 year ago

Issue resolved itself once a setup:upgrade was run for a different issue. Site is in developer mode so a cache:flush|clean should have been all that was needed to invoke this change. Perhaps you could investigate why whatever cache that held onto the old values was only flushed with a setup:upgrade instead of a cache:flush|clean.

Perhaps you could also consider implementing a cache:nuke command that properly clears all caches so next page load starts from the actual active codebase/database. It's quite ridiculous that we have to intermittently resort to manually deleting various files/folders to ensure we're actually using the code/config as specificied.

m2-assistant[bot] commented 1 year ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 1 year ago

Hello @adamlavery,

Thanks for the reporting and collaboration!

We have tried to reproduce the issue in the latest 2.4-develop branch and the issue is reproducible for us. We have followed the below steps in order to reproduce the issue:

  1. Add below translations in the files app/design/adminhtml/Magento/backend/i18n/en_US.csv and app/design/frontend/Magento/luma/i18n/en_US.csv:

    "Please enter less or equal than %1 symbols.","Please enter maximum %1 characters."
    "Please enter more or equal than %1 symbols.","Please enter minimum %1 characters."
    "Please enter more or equal than {0} symbols.","Please enter maximum {0} characters."
    "Please enter less or equal than {0} symbols.","Please enter minimum {0} characters."
    "Edit item parameters","Edit item"
    "Subscribe", "Start Saving"
  2. Run the below commands to clear the cache:

    bin/magento c:c
    bin/magento c:f
  3. Refresh the frontend and check the translations, this is translating well: image

  4. Check this path for other translations Admin Panel -> Marketing -> SEO & Search -> Site Map -> Add Sitemap and try to add text greater than 32 characters in the Filename field. New translations is not applied: New-Site-Map-Site-Map-SEO-Search-Marketing-Magento-Admin

  5. But after running bin/magento setup:upgrade translations are working: 2-New-Site-Map-Site-Map-SEO-Search-Marketing-Magento-Admin

Hence confirming the issue.

Thanks

github-jira-sync-bot commented 1 year ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-7541 is successfully created for this GitHub issue.

m2-assistant[bot] commented 1 year ago

:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.