0

In the "file vendor/magento/module-ui/view/base/web/js/lib/validation/rules.js" in line 433 Magento2 can't translate this sentence. rules.js file of translate But after remove "+" the translation is perfect.

How I can translate correct without rewrite "rules.js"?

1 Answer 1

0

Translation behavior depends on strategy set in Stores -> Configuration -> Advanced -> Developer -> JavaScript Setting -> Translation Strategy.

Take a look at full explanation here: What is the Translation Strategy

However, both strategies rely on regex pattern for replacing/collecting translatable strings. So the problem here is that string does not match the pattern.

So the only solution I see, without overriding rules.js, is to add the pattern for gathering translation files. You can do it from your module's di.xml like:

<type name="Magento\Translation\Model\Js\Config"> <arguments> <argument name="patterns" xsi:type="array"> <item name="custom_pattern" xsi:type="string">~regex-pattern~</item> </argument> </arguments> </type> 

See existing patterns here: https://github.com/magento/magento2/blob/develop/app/code/Magento/Translation/etc/di.xml#L63

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.