Skip to content

Commit 4d1c645

Browse files
committed
MAGETWO-34390: Stabilization of replacing Zend_Locale with Native PHP Implementation
1 parent 379878e commit 4d1c645

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

dev/tests/unit/testsuite/Magento/Setup/Model/ListsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
namespace Magento\Setup\Model;
88

9-
use Magento\TestFramework\Helper\ObjectManager;
10-
119
class ListsTest extends \PHPUnit_Framework_TestCase
1210
{
1311
/**

lib/internal/Magento/Framework/Locale/Bundle/DataBundle.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class DataBundle
2525
*/
2626
public function get($locale)
2727
{
28+
$locale = $this->cleanLocale($locale);
2829
$class = get_class($this);
2930
if (!isset(static::$bundles[$class][$locale])) {
3031
$bundle = new \ResourceBundle($locale, $this->path);
@@ -35,4 +36,23 @@ public function get($locale)
3536
}
3637
return static::$bundles[$class][$locale];
3738
}
39+
40+
/**
41+
* Clean locale leaving only language and script
42+
*
43+
* @param string $locale
44+
* @return string
45+
*/
46+
protected function cleanLocale($locale)
47+
{
48+
$localeParts = \Locale::parseLocale($locale);
49+
$cleanLocaleParts = [];
50+
if (isset($localeParts['language'])) {
51+
$cleanLocaleParts['language'] = $localeParts['language'];
52+
}
53+
if (isset($localeParts['script'])) {
54+
$cleanLocaleParts['script'] = $localeParts['script'];
55+
}
56+
return \Locale::composeLocale($cleanLocaleParts);
57+
}
3858
}

lib/internal/Magento/Framework/Locale/Lists.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ public function getOptionWeekdays($preserveCodes = false, $ucFirstCode = false)
126126
$days = (new DataBundle())->get(
127127
$this->localeResolver->getLocale()
128128
)['calendar']['gregorian']['dayNames']['format']['wide'];
129-
$englishDays = (new DataBundle())->get(
130-
'en_US',
131-
'ICUDATA'
132-
)['calendar']['gregorian']['dayNames']['format']['abbreviated'];
129+
$englishDays = (new DataBundle())->get('en_US')['calendar']['gregorian']['dayNames']['format']['abbreviated'];
133130
foreach ($days as $code => $name) {
134131
$code = $preserveCodes ? $englishDays[$code] : $code;
135132
$options[] = ['label' => $name, 'value' => $ucFirstCode ? ucfirst($code) : $code];

0 commit comments

Comments
 (0)