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); // $line = str_replace(array("\r\n","\n","\r"), '', $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) { if ($this->debug) { echo "\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n"; echo "\t%%%% newEnt %%%%%%%%% newEnt %%%%%%%%% newEnt %%%%%%%%% newEnt %%%%%\n"; echo "\t%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n\n"; var_dump($parsedEnt); } if (!isset($parsedEnt["diff"]) && !isset($parsedEnt["index"])) $parsedEnt["index"] = $parsedEnt["internal_index"]; $entities[] = $parsedEnt; $parsedEnt =array(); $newEnt = false; } if ($parsedLine["type"] == "internal_index") $parsedEnt["internal_index"] = $parsedLine["index"]; if ($parsedLine["type"] == "string") { $prevStringLine = true; if ($this->debug) { echo "%%%% parsedEnt %%%%%\n"; var_dump($parsedEnt); // echo "%%%% parsedLine %%%%%\n"; // var_dump($parsedLine); } if (!$parsedLine['identifier']) { if ($this->debug) echo "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"; $parsedEnt['string'] .= "\n" . $parsedLine['string']; } 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) { if (!isset($parsedEnt["diff"]) && !isset($parsedEnt["index"])) $parsedEnt["index"] = $parsedEnt["internal_index"]; $entities[] = $parsedEnt; } 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 = ''; 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*/ if (!isset($ent['command'])) $content .= '// INDEX ' . $ent['index'] . "\n"; $content .= $ent['identifier'] . "\t" . '[' . $ent['string'] . ']' . "\n"; $content .= "\n"; } return $this->addBOM($this->CRLF($content)); } } ?>