stream = $header;
}
function getStream()
{
return $this->stream;
}
function addComment($param, $value)
{
$this->stream .= '#. ' . $param . ': ' . str_replace("\r\n", ' ', $value) . PHP_EOL;
}
function addMsgctxt($msgctxt)
{
if (strpos($msgctxt, "
") !== false || strpos($msgctxt, "\r\n") !== false) {
$msgctxt = strpos($msgctxt, "\r\n") !== false ? explode("\r\n", $msgctxt) : explode("
", $msgctxt);
$this->stream .= 'msgctxt ""' . PHP_EOL;
for ($i = 0; $i < count($msgctxt); $i++) {
$msgctxt[$i] = strpos($msgctxt[$i], "\r\n") !== false ? $msgctxt[$i] : preg_replace("/\r|\n/", "", $msgctxt[$i]);
if ($i == 0) {
$this->stream .= '",' . $msgctxt[$i] . '\\n"';
} else {
if ($i == count($msgctxt) - 1)
$this->stream .= '"' . $msgctxt[$i] . '"';
else
$this->stream .= '"' . $msgctxt[$i] . '\\n"';
}
$this->stream .= PHP_EOL;
}
} else {
$this->stream .= 'msgctxt ' . '",' . $msgctxt . '"' . PHP_EOL;
}
}
function addMsgID($msgID)
{
if (strpos($msgID, "
") !== false || strpos($msgID, "\r\n") !== false) {
$msgID = strpos($msgID, "\r\n") !== false ? explode("\r\n", $msgID) : explode("
", $msgID);
$this->stream .= 'msgid ""' . PHP_EOL;
for ($i = 0; $i < count($msgID); $i++) {
$msgID[$i] = strpos($msgID[$i], "\r\n") !== false ? $msgID[$i] : preg_replace("/\r|\n/", "", $msgID[$i]);
if ($i == count($msgID) - 1)
$this->stream .= '"' . $msgID[$i] . '"';
else
$this->stream .= '"' . $msgID[$i] . '\\n"';
$this->stream .= PHP_EOL;
}
} else {
$this->stream .= 'msgid ' . '"' . $msgID . '"' . PHP_EOL;
}
}
function addMsgSTR($msgStr)
{
if (strpos($msgStr, "
") !== false) {
$msgStr = explode("
", $msgStr);
$this->stream .= 'msgstr ""' . PHP_EOL;
for ($i = 0; $i < count($msgStr); $i++) {
$msgStr[$i] = preg_replace("/\r|\n/", "", $msgStr[$i]);
if ($i == count($msgStr) - 1)
$this->stream .= '"' . $msgStr[$i] . '"';
else
$this->stream .= '"' . $msgStr[$i] . '\\n"';
$this->stream .= PHP_EOL;
}
$this->stream .= PHP_EOL;
} else {
$this->stream .= 'msgstr ' . '"' . $msgStr . '"' . PHP_EOL . PHP_EOL;
}
}
}