File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
app/code/Magento/Translation/Model/Js Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,11 @@ class PreProcessor implements PreProcessorInterface
35
35
*/
36
36
protected $ translate ;
37
37
38
+ /**
39
+ * @var array
40
+ */
41
+ protected $ areasThemesLocales = [];
42
+
38
43
/**
39
44
* @param Config $config
40
45
* @param AreaList $areaList
@@ -63,6 +68,7 @@ public function process(Chain $chain)
63
68
if ($ context instanceof FallbackContext) {
64
69
$ areaCode = $ context ->getAreaCode ();
65
70
$ this ->translate ->setLocale ($ context ->getLocale ());
71
+ $ this ->loadTranslationDataBasedOnThemesAndLocales ($ context );
66
72
}
67
73
68
74
$ area = $ this ->areaList ->getArea ($ areaCode );
@@ -96,4 +102,23 @@ protected function replaceCallback($matches)
96
102
{
97
103
return '\'' . __ ($ matches ['translate ' ]) . '\'' ;
98
104
}
105
+
106
+ /**
107
+ * Load translation data based on themes and locales.
108
+ *
109
+ * @param FallbackContext $context
110
+ * @return void
111
+ */
112
+ public function loadTranslationDataBasedOnThemesAndLocales (FallbackContext $ context ): void
113
+ {
114
+ if (!isset ($ this ->areasThemesLocales [$ context ->getAreaCode ()]
115
+ [$ context ->getThemePath ()]
116
+ [$ context ->getLocale ()]
117
+ )) {
118
+ $ this ->areasThemesLocales [$ context ->getAreaCode ()]
119
+ [$ context ->getThemePath ()]
120
+ [$ context ->getLocale ()] = true ;
121
+ $ this ->translate ->loadData ($ context ->getAreaCode (), false );
122
+ }
123
+ }
99
124
}
You can’t perform that action at this time.
0 commit comments