Skip to content

Commit 070904e

Browse files
authored
ENGCOM-5990: Static Content Deploy - Sort JS Translations to have them in the same order on every build #24828
2 parents 2c91b68 + 4d8c515 commit 070904e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ public function getData($themePath)
120120
}
121121
}
122122

123+
ksort($dictionary);
124+
123125
return $dictionary;
124126
}
125127

app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function testGetData()
9090
$themePath = 'blank';
9191
$areaCode = 'adminhtml';
9292

93-
$filePaths = [['path1'], ['path2'], ['path3'], ['path4']];
93+
$filePaths = [['path1'], ['path2'], ['path4'], ['path3']];
9494

9595
$jsFilesMap = [
9696
['base', $themePath, '*', '*', [$filePaths[0]]],
@@ -111,8 +111,8 @@ public function testGetData()
111111
$contentsMap = [
112112
'content1$.mage.__("hello1")content1',
113113
'content2$.mage.__("hello2")content2',
114+
'content2$.mage.__("hello4")content4', // this value should be last after running data provider
114115
'content2$.mage.__("hello3")content3',
115-
'content2$.mage.__("hello4")content4'
116116
];
117117

118118
$translateMap = [
@@ -147,7 +147,13 @@ public function testGetData()
147147
->method('render')
148148
->willReturnMap($translateMap);
149149

150-
$this->assertEquals($expectedResult, $this->model->getData($themePath));
150+
$actualResult = $this->model->getData($themePath);
151+
$this->assertEquals($expectedResult, $actualResult);
152+
$this->assertEquals(
153+
json_encode($expectedResult),
154+
json_encode($actualResult),
155+
"Translations should be sorted by key"
156+
);
151157
}
152158

153159
/**

0 commit comments

Comments
 (0)