cancel
Showing results for 
Search instead for 
Did you mean: 

magento2 translate error

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

magento2 translate error

Hi.

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

cReF6.jpg

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?

 

1 REPLY 1

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">
    <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