Skip to content

Commit f895075

Browse files
MAGETWO-82752: Fixes translations by re-running the loadData for its correct locale #10913
2 parents e52b762 + d641a93 commit f895075

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,13 @@ public function process(Chain $chain)
7777
if ($context instanceof FallbackContext) {
7878
$themePath = $context->getThemePath();
7979
$areaCode = $context->getAreaCode();
80-
$this->translate->setLocale($context->getLocale());
8180
}
8281

8382
$area = $this->areaList->getArea($areaCode);
8483
$area->load(\Magento\Framework\App\Area::PART_TRANSLATE);
8584

85+
$this->translate->setLocale($context->getLocale())->loadData($areaCode, true);
86+
8687
$chain->setContent(json_encode($this->dataProvider->getData($themePath)));
8788
$chain->setContentType('json');
8889
}

app/code/Magento/Translation/Test/Unit/Model/Json/PreProcessorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ public function testGetData()
8080
$context->expects($this->once())
8181
->method('getAreaCode')
8282
->willReturn($areaCode);
83+
$context->expects($this->once())
84+
->method('getLocale')
85+
->willReturn('en_US');
8386

8487
$this->areaListMock->expects($this->once())
8588
->method('getArea')
@@ -97,6 +100,9 @@ public function testGetData()
97100
->method('setContentType')
98101
->with('json');
99102

103+
$this->translateMock->expects($this->once())->method('setLocale')->with('en_US')->willReturnSelf();
104+
$this->translateMock->expects($this->once())->method('loadData')->with($areaCode, true);
105+
100106
$this->model->process($chain);
101107
}
102108
}

0 commit comments

Comments
 (0)