Parsed data is an array where keys are nodes from XML file with its attributes (if any). Only distinguishing attributes are taken into account (see [1]). Below are examples of parsed data structure. such XML data: will be converted to such array: array( 'dates' => array( 'calendars' => array( 'calendar[@type="gregorian"]' => array( 'months' => '' ), 'calendar[@type="buddhist"]' => array( 'months' => '' ), ) ) )
See also: http://www.unicode.org/reports/tr35/#Inheritance_and_Validity [1]
Inheritance: extends Neos\Flow\I18n\AbstractXmlParser
コード例 #1
0
 /**
  * @test
  */
 public function parsesCldrDataCorrectly()
 {
     $sampleFilenamePath = __DIR__ . '/../Fixtures/MockCldrData.xml';
     $sampleParsedData = (require __DIR__ . '/../Fixtures/MockParsedCldrData.php');
     $parser = new I18n\Cldr\CldrParser();
     $result = $parser->getParsedData($sampleFilenamePath);
     $this->assertEquals($sampleParsedData, $result);
 }
コード例 #2
0
 /**
  * Parses given CLDR files using CldrParser and merges parsed data.
  *
  * Merging is done with inheritance in mind, as defined in CLDR specification.
  *
  * @param array<string> $sourcePaths Absolute paths to CLDR files (can be one file)
  * @return array Parsed and merged data
  */
 protected function parseFiles(array $sourcePaths)
 {
     $parsedFiles = [];
     foreach ($sourcePaths as $sourcePath) {
         $parsedFiles[] = $this->cldrParser->getParsedData($sourcePath);
     }
     // Merge all data starting with most generic file so we get proper inheritance
     $parsedData = $parsedFiles[0];
     $parsedFilesCount = count($parsedFiles);
     for ($i = 1; $i < $parsedFilesCount; ++$i) {
         $parsedData = $this->mergeTwoParsedFiles($parsedData, $parsedFiles[$i]);
     }
     return $parsedData;
 }