/** * @test */ public function returnsAttributeValueCorrectly() { $sampleNodeString = 'dateFormatLength[@type="medium"][@alt="proposed"]'; $this->assertEquals('medium', $this->model->getAttributeValue($sampleNodeString, 'type')); $this->assertEquals('proposed', $this->model->getAttributeValue($sampleNodeString, 'alt')); $this->assertEquals(FALSE, $this->model->getAttributeValue($sampleNodeString, 'dateFormatLength')); }
/** * Parses "eras" child of "dates" node and returns it's array representation. * * @param \TYPO3\Flow\I18n\Cldr\CldrModel $model CldrModel to read data from * @return array An array with localized literals for "eras" node */ protected function parseLocalizedEras(\TYPO3\Flow\I18n\Cldr\CldrModel $model) { $data = array(); foreach ($model->getRawArray('dates/calendars/calendar[@type="gregorian"]/eras') as $widthType => $eras) { foreach ($eras as $eraNodeString => $eraValue) { $eraName = $model->getAttributeValue($eraNodeString, 'type'); $data[$widthType][$eraName] = $eraValue; } } return $data; }
/** * Get an array of all values in the CLDR where the key is the type attribute * * @param string $path The xpath to select values from * @return array|boolean */ protected function getKeyValues($path) { $defaultLocale = $this->detector->detectLocaleFromLocaleTag('en'); $model = $this->cldrRepository->getModelForLocale($defaultLocale); $data = $model->getRawArray($path); if ($data === FALSE) { return FALSE; } $filteredData = array(); foreach ($data as $nodeString => $children) { if (CldrModel::getAttributeValue($nodeString, 'alt') === FALSE) { $key = CldrModel::getAttributeValue($nodeString, 'type'); $filteredData[$key] = $children; } } return $filteredData; }