This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
\n\n"; } $line_no=1; foreach ($lines as $line) { if ($this->debug) { echo "\n\t#################### LINE NUMBER " . $line_no++ . "\n\n"; var_dump($line); } $line = rtrim($line, "\r\n"); $parsedLine = $this->parseLine($line); if ($this->debug) { echo "%%%% parsedLine\n"; var_dump($parsedLine); echo "\n"; echo "%%%% prevStringLine\n"; var_dump($prevStringLine); echo "\n"; } if (!$parsedLine) continue; // if line start with diff (diff files) or hash_value (translated files) and before was line with translation, then we start new ent if ($prevStringLine && ( ($parsedLine["type"] == "diff" && $parsedEnt) || ($parsedLine["type"] == "hash_value" && $parsedEnt) )) { /* echo "%%%% prevStringLine %%%%%\n"; var_dump($parsedEnt);*/ $newEnt = true; } if ($newEnt) { $this->addEnt($parsedEnt, $entities, $newEnt); } if ($parsedLine["type"] == "internal_index") $parsedEnt["internal_index"] = $parsedLine["index"]; if ($parsedLine["type"] == "string") { $prevStringLine = true; if ($parsedLine["body"] == "begin" || $parsedLine["body"] == "end") continue; if ($this->debug) { echo "%%%% parsedEnt before %%%%%\n"; var_dump($parsedEnt); // echo "%%%% parsedLine %%%%%\n"; // var_dump($parsedLine); } if (!$parsedLine['identifier']) { if ($this->debug) echo "%%%% parsedEnt ZLACZENIE \n"; if ($this->debug && !isset($parsedEnt['string'])) { echo "!isset parsedEnt['string']\n"; var_dump($line); var_dump($parsedEnt); var_dump($parsedLine); } $parsedEnt['string'] .= $parsedLine['string'] . "\n"; } else { if ($this->debug) echo "DODANIE \n"; $parsedEnt += $parsedLine; // $parsedEnt['string'] .= "\n"; } if ($this->debug) { echo "%%%% parsedEnt after %%%%%\n"; var_dump($parsedEnt); } } else $prevStringLine = false; if ($parsedLine["type"] == "diff") { $parsedEnt["diff"] = $parsedEnt["command"] = $parsedLine["command"]; $parsedEnt["index"] = $parsedLine["index"]; } } if ($parsedEnt) { $this->addEnt($parsedEnt, $entities, $newEnt); } if ($this->debug) { echo ""; var_dump($entities); echo "\n"; } return $entities; } function CRLF($s) { $s = str_replace("\r\n", "\n", $s); $s = str_replace("\n", "\r\n", $s); return $s; } function buildFile($entities) { $content = '// DIFF_VERSION 2' . "\n"; foreach ($entities as $ent) { if (isset($ent['command'])) $content .= '// ' . $ent['command'] . "\n"; if (isset($ent['hash_value'])) $content .= '// HASH_VALUE ' . $ent['hash_value']; /* if (isset($ent['command'])) $content .= '// INDEX ' . $ent['internal_index'] . "\n"; else $content .= '// INDEX ' . $ent['index'] . "\n";*/ $content .= $ent['identifier'] . ' (' . $ent['arguments'] . ')' . "\n" . '{' . "\n" . $ent['string'] . "\n" . '}' . "\n"; $content .= "\n"; } return $this->addBOM($this->CRLF($content)); } } ?>