Skip to content

Commit 73372e8

Browse files
committed
ACP2E-682: [Magento Cloud] - Add to cart button translation reverts back to English after clicking
- Fixed the solution.
1 parent d86eafe commit 73372e8

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

app/code/Magento/Translation/Model/Js/PreProcessor.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class PreProcessor implements PreProcessorInterface
3535
*/
3636
protected $translate;
3737

38+
/**
39+
* @var array
40+
*/
41+
protected $areasThemesLocales = [];
42+
3843
/**
3944
* @param Config $config
4045
* @param AreaList $areaList
@@ -63,6 +68,7 @@ public function process(Chain $chain)
6368
if ($context instanceof FallbackContext) {
6469
$areaCode = $context->getAreaCode();
6570
$this->translate->setLocale($context->getLocale());
71+
$this->loadTranslationDataBasedOnThemesAndLocales($context);
6672
}
6773

6874
$area = $this->areaList->getArea($areaCode);
@@ -96,4 +102,23 @@ protected function replaceCallback($matches)
96102
{
97103
return '\'' . __($matches['translate']) . '\'';
98104
}
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+
}
99124
}

0 commit comments

Comments
 (0)