Skip to content

Commit

Permalink
Allow extraction of DateIntervalType labels option
Browse files Browse the repository at this point in the history
  • Loading branch information
fchris82 committed Feb 27, 2018
1 parent 1df3aa4 commit ec84710
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Translation/Extractor/File/FormExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public function enterNode(Node $node)
case 'label':
$this->parseItem($item, $domain);
break;
case 'labels':
if ($this->parseLabelsNode($item, $node, $domain)) {
continue 2;
}
$this->parseItem($item, $domain);
break;
case 'invalid_message':
$this->parseItem($item, 'validators');
break;
Expand Down Expand Up @@ -242,6 +248,32 @@ public function getDomain(Node $node)
return $domain;
}

/**
* This parses any Node of type labels.
*
* Returning true means either that regardless of whether
* parsing has occurred or not, the enterNode function should move on to the next node item.
*
* @param Node $item
* @param Node $node
* @param $domain
* @return bool
* @internal
*/
protected function parseLabelsNode(Node $item, Node $node, $domain)
{
// Skip any labels that aren't arrays
if (!$item->value instanceof Node\Expr\Array_) {
return true;
}

foreach ($item->value->items as $subItem) {
$this->parseItem($subItem, $domain);
}

return true;
}

/**
* This parses any Node of type empty_value.
*
Expand Down

0 comments on commit ec84710

Please sign in to comment.