https://github.com/magesuite/js-translation-fix
Fixes JS translation gathering for minified assets.
Installation
This module is a part of MageSuite metapackage
Installation if metapackage is not used:
composer require "creativestyle/magesuite-js-translation-fix" ^1.0.0
Admin settings
There are no admin settings, the module is enabled by default.
Frontend
The module was introduced because Magesuite workflow minifies our JS code before Magento searches for wordings and it could not find them. An additional regexp was added, that allows Magento to find Magesuite strings. Basically Magento searches (among others) for $.mage.__()
or jQuery.mage.__()
, but after minification the result is x.mage.__()
where x
can be anything. The new regexp skips the prefix and searches only for .mage.__()
.
https://github.com/magesuite/js-translation-fix/blob/1.x/etc/di.xml
<type name="Magento\Translation\Model\Js\Config"> <arguments> <argument name="patterns" xsi:type="array"> <item name="cs_translation_widget" xsi:type="string"><![CDATA[~\.mage\.__\((?s)[^'"]*?(['"])(.+?)(?<!\\)\1(?s).*?\)~]]></item> </argument> </arguments> </type>
Review of documentation is needed