Showing results for 
Search instead for 
Did you mean: 

magento2 translate error

magento2 translate error


In the "file vendor/magento/module-ui/view/base/web/js/lib/validation/rules.js" in line 433 Magento2 can't translate this sentence.


But after remove "+" and line break the translation is perfect.

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

For which the file was formatted so, if this formatting breaks the basic functional?



Re: magento2 translate error

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">
        <argument name="patterns" xsi:type="array">
            <item name="custom_pattern" xsi:type="string">~regex-pattern~</item>

See existing patterns here: