function load($file = null)
{
if (!isset($file)) {
$file = $this->file;
}
// load file
if (!($contents = @file($file))) {
return false;
}
$contents = implode('', $contents);
// match all msgid/msgstr entries
$matched = preg_match_all('/(msgid\\s+("([^"]|\\\\")*?"\\s*)+)\\s+' . '(msgstr\\s+("([^"]|\\\\")*?"\\s*)+)/', $contents, $matches);
unset($contents);
if (!$matched) {
return false;
}
// get all msgids and msgtrs
for ($i = 0; $i < $matched; $i++) {
$msgid = preg_replace('/\\s*msgid\\s*"(.*)"\\s*/s', '\\1', $matches[1][$i]);
$msgstr = preg_replace('/\\s*msgstr\\s*"(.*)"\\s*/s', '\\1', $matches[4][$i]);
$this->strings[parent::prepare($msgid)] = parent::prepare($msgstr);
}
// check for meta info
if (isset($this->strings[''])) {
$this->meta = parent::meta2array($this->strings['']);
unset($this->strings['']);
}
return true;
}