protected function parse(array $chunks)
{
foreach ($chunks as $chunk) {
if (preg_match('/^"(.*)"/', $chunk, $matches)) {
$this->{$lastChunkType} .= $matches[1];
continue;
}
if (preg_match('/^msgid "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'msgid';
$this->msgid = $matches[1];
} elseif (preg_match('/^msgstr "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'msgstr';
$this->msgstr = $matches[1];
} elseif (preg_match('/^#~ msgid "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'msgid';
$this->obsolete = true;
$this->msgid = $matches[1];
} elseif (preg_match('/^#~ msgstr "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'msgstr';
$this->obsolete = true;
$this->msgstr = $matches[1];
} elseif (preg_match('/^(#: .+)$/', $chunk, $matches)) {
$lastChunkType = 'location';
$this->location .= $matches[1];
} elseif (preg_match('/^#, fuzzy/', $chunk)) {
$lastChunkType = 'fuzzy';
$this->fuzzy = true;
} elseif (preg_match('/^msgid_plural "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'plural';
$this->plural = $matches[1];
$this->msgstr = [];
} elseif (preg_match('/^msgstr\\[([0-9])+\\] "(.*)"/', $chunk, $matches)) {
$lastChunkType = 'msgstr';
$this->msgstr[$matches[1]] = $matches[2];
}
}
}