Skip to content

Some strings not translatable in M2.4.1 #31849

Closed
@siimm

Description

@siimm

Preconditions (*)

  1. Clean Magento 2.4.1 installation
  2. 2.4-develop

Steps to reproduce (*)

  1. Add a product to cart
  2. Navigate to cart page
  3. Open admin interface, find the product, save it as "Out of Stock"
  4. Refresh cart page, see error message: There are no source items with the in stock status
  5. Find the translation for the message in vendor/magento/module-catalog-inventory/i18n/en_US.csv
  6. Change the result string to be something else
  7. Clean "translate" cache
  8. Refresh the cart page and witness the previously mentioned string being not translated to value we changed it at point 6

Expected result (*)

  1. Error messages are translated

Actual result (*)

  1. Error messages are not translated - can be verified even with default en_US language - change the translation for the error message

NOTES

The steps to reproduce part only highlights one specific string, however this seems to be a more general problem:

Due to update of design (and translations) loading in b2a035d
(loading design and translations was moved from beforeDispatch to beforeExecute)

However there are several plugins in M2 ecosystem, which come before actual execute call, \Magento\InventorySales\Model\IsProductSalableForRequestedQtyCondition\IsProductSalableForRequestedQtyConditionChain is one of the many examples (on quote loading, validation is triggered).

Verified this in clean Magento 2.4.1 - the error phrase is never translated, as renderers for Phrase is set only in \Magento\Theme\Plugin\LoadDesignPlugin::beforeExecute

This happens due to renderer not being set to \Magento\Framework\Phrase, and if it is used earlier than the renderers are set - the original string gets returned, as it uses the RendererPlaceholder class to render them.

With current state, a lot of strings cannot be translated, the only imaginable workaround is to move design and translations loading back to beforeDispatch method. (Moving just the translation loading to beforeDispatch won't help, if the translations are in theme.)

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • < ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • [ > Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Issue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P1Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing.Progress: doneReported on 2.4.1Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions