Skip to content

Commit

Permalink
Fixes zendframework#516 - Zend_Locale does not honor parentLocale con…
Browse files Browse the repository at this point in the history
…figuration
  • Loading branch information
froschdesign authored and antonis179 committed Jan 11, 2018
1 parent 6d71842 commit af0f92c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions library/Zend/Locale/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ private static function _getFile($locale, $path, $attribute = false, $value = fa
// 3. -> zh
// 4. -> root
if (($locale != 'root') && ($result)) {
// Search for parent locale
if (false !== strpos($locale, '_')) {
$parentLocale = self::getContent($locale, 'parentlocale');
if ($parentLocale) {
$temp = self::_getFile($parentLocale, $path, $attribute, $value, $temp);
}
}

$locale = substr($locale, 0, -strlen(strrchr($locale, '_')));
if (!empty($locale)) {
$temp = self::_getFile($locale, $path, $attribute, $value, $temp);
Expand Down
9 changes: 9 additions & 0 deletions tests/Zend/Locale/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7281,4 +7281,13 @@ public function testGetParentLocale()
$result = Zend_Locale_Data::getContent('de_DE', 'parentlocale');
$this->assertFalse($result);
}

/**
* @group GH-516
*/
public function testLocaleWhichHasParentLocale()
{
$result = Zend_Locale_Data::getContent('en_HK', 'nametocurrency', 'XAF');
$this->assertEquals('Central African CFA Franc', $result);
}
}

0 comments on commit af0f92c

Please sign in to comment.