Sfoglia il codice sorgente

Fixes #516 - Zend_Locale does not honor parentLocale configuration

Frank Brückner 10 anni fa
parent
commit
116681bf9d
2 ha cambiato i file con 17 aggiunte e 0 eliminazioni
  1. 8 0
      library/Zend/Locale/Data.php
  2. 9 0
      tests/Zend/Locale/DataTest.php

+ 8 - 0
library/Zend/Locale/Data.php

@@ -241,6 +241,14 @@ class Zend_Locale_Data
         // 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);

+ 9 - 0
tests/Zend/Locale/DataTest.php

@@ -7282,4 +7282,13 @@ class Zend_Locale_DataTest extends PHPUnit_Framework_TestCase
         $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);
+    }
 }