protected function parse(string $file)
{
$linenumber = 0;
$chunks = [];
$file = file($file);
foreach ($file as $line) {
if ($line == "\n" || $line == "\r\n") {
++$linenumber;
} else {
if (!array_key_exists($linenumber, $chunks)) {
$chunks[$linenumber] = '';
}
$chunks[$linenumber] .= $line;
}
}
$header = array_shift($chunks);
$this->header = new $this->headerClass($header);
foreach ($chunks as $chunk) {
try {
$this->items[] = new $this->itemClass($chunk);
} catch (\Jyxo\Gettext\Parser\Exception $e) {
// Do nothing, msgid is empty
}
}
}