7
7
8
8
namespace Magento \Translation \Model \Js ;
9
9
10
+ use Magento \Deploy \Console \DeployStaticOptions ;
10
11
use Magento \Framework \App \AreaList ;
11
12
use Magento \Framework \TranslateInterface ;
12
13
use Magento \Framework \View \Asset \File \FallbackContext ;
13
14
use Magento \Framework \View \Asset \PreProcessor \Chain ;
14
15
use Magento \Framework \View \Asset \PreProcessorInterface ;
16
+ use Symfony \Component \Console \Input \ArgvInput ;
17
+ use Magento \Deploy \Strategy \DeployStrategyFactory ;
15
18
16
19
/**
17
20
* PreProcessor responsible for replacing translation calls in js files to translated strings
@@ -40,16 +43,27 @@ class PreProcessor implements PreProcessorInterface
40
43
*/
41
44
protected $ areasThemesLocales = [];
42
45
46
+ /**
47
+ * @var ArgvInput
48
+ */
49
+ private $ input ;
50
+
43
51
/**
44
52
* @param Config $config
45
53
* @param AreaList $areaList
46
54
* @param TranslateInterface $translate
55
+ * @param ArgvInput $input
47
56
*/
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
+ ) {
50
63
$ this ->config = $ config ;
51
64
$ this ->areaList = $ areaList ;
52
65
$ this ->translate = $ translate ;
66
+ $ this ->input = $ input ;
53
67
}
54
68
55
69
/**
@@ -74,7 +88,11 @@ public function process(Chain $chain)
74
88
$ area = $ this ->areaList ->getArea ($ areaCode );
75
89
$ area ->load (\Magento \Framework \App \Area::PART_TRANSLATE );
76
90
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
+ }
78
96
}
79
97
}
80
98
@@ -120,4 +138,24 @@ public function loadTranslationDataBasedOnThemesAndLocales(FallbackContext $cont
120
138
$ this ->translate ->loadData ($ context ->getAreaCode (), false );
121
139
}
122
140
}
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
+ }
123
161
}
0 commit comments