77
88namespace Magento \Translation \Model \Js ;
99
10+ use Magento \Deploy \Console \DeployStaticOptions ;
1011use Magento \Framework \App \AreaList ;
1112use Magento \Framework \TranslateInterface ;
1213use Magento \Framework \View \Asset \File \FallbackContext ;
1314use Magento \Framework \View \Asset \PreProcessor \Chain ;
1415use Magento \Framework \View \Asset \PreProcessorInterface ;
16+ use Symfony \Component \Console \Input \ArgvInput ;
17+ use Magento \Deploy \Strategy \DeployStrategyFactory ;
1518
1619/**
1720 * PreProcessor responsible for replacing translation calls in js files to translated strings
@@ -40,16 +43,27 @@ class PreProcessor implements PreProcessorInterface
4043 */
4144 protected $ areasThemesLocales = [];
4245
46+ /**
47+ * @var ArgvInput
48+ */
49+ private $ input ;
50+
4351 /**
4452 * @param Config $config
4553 * @param AreaList $areaList
4654 * @param TranslateInterface $translate
55+ * @param ArgvInput $input
4756 */
48- public function __construct (Config $ config , AreaList $ areaList , TranslateInterface $ translate )
49- {
57+ public function __construct (
58+ Config $ config ,
59+ AreaList $ areaList ,
60+ TranslateInterface $ translate ,
61+ ArgvInput $ input
62+ ) {
5063 $ this ->config = $ config ;
5164 $ this ->areaList = $ areaList ;
5265 $ this ->translate = $ translate ;
66+ $ this ->input = $ input ;
5367 }
5468
5569 /**
@@ -74,7 +88,11 @@ public function process(Chain $chain)
7488 $ area = $ this ->areaList ->getArea ($ areaCode );
7589 $ area ->load (\Magento \Framework \App \Area::PART_TRANSLATE );
7690
77- $ chain ->setContent ($ this ->translate ($ chain ->getContent ()));
91+ if (!$ this ->isCheckStrategyCompact ()) {
92+ $ chain ->setContent ($ this ->translate ($ chain ->getContent ()));
93+ } else {
94+ $ chain ->setContent ($ chain ->getContent ());
95+ }
7896 }
7997 }
8098
@@ -120,4 +138,24 @@ public function loadTranslationDataBasedOnThemesAndLocales(FallbackContext $cont
120138 $ this ->translate ->loadData ($ context ->getAreaCode (), false );
121139 }
122140 }
141+
142+ /**
143+ * Check deploy argument strategy is compact.
144+ *
145+ * @return bool
146+ */
147+ public function isCheckStrategyCompact (): bool
148+ {
149+ $ isCompact = false ;
150+ $ isStrategy = $ this ->input ->hasParameterOption ('-- ' . DeployStaticOptions::STRATEGY ) ||
151+ $ this ->input ->hasParameterOption ('-s ' );
152+ if ($ isStrategy ) {
153+ $ strategyValue = $ this ->input ->getParameterOption ('-- ' . DeployStaticOptions::STRATEGY ) ?:
154+ $ this ->input ->getParameterOption ('-s ' );
155+ if ($ strategyValue === DeployStrategyFactory::DEPLOY_STRATEGY_COMPACT ) {
156+ $ isCompact = true ;
157+ }
158+ }
159+ return $ isCompact ;
160+ }
123161}
0 commit comments