14        $lines = array(
'msgid ""', 
'msgstr ""');
 
   17        $headers[
'PO-Revision-Date'] = date(
'c');
 
   19        foreach ($headers as 
$name => $value) {
 
   20            $lines[] = 
'"'.$name.
': '.$value.
'\\n"';
 
   26        foreach ($translations as $translation) {
 
   27            if ($translation->hasComments()) {
 
   28                foreach ($translation->getComments() as 
$comment) {
 
   29                    $lines[] = 
'# '.$comment;
 
   33            if ($translation->hasExtractedComments()) {
 
   34                foreach ($translation->getExtractedComments() as 
$comment) {
 
   35                    $lines[] = 
'#. '.$comment;
 
   39            if ($translation->hasReferences()) {
 
   40                foreach ($translation->getReferences() as $reference) {
 
   41                    $lines[] = 
'#: '.$reference[0].(!is_null($reference[1]) ? 
':'.$reference[1] : 
null);
 
   45            if ($translation->hasFlags()) {
 
   46                $lines[] = 
'#, '.implode(
',', $translation->getFlags());
 
   49            if ($translation->hasContext()) {
 
   50                $lines[] = 
'msgctxt '.self::convertString($translation->getContext());
 
   54            if ($translation->hasPlural()) {
 
   56                self::addLines($lines, 
'msgstr[0]', $translation->getTranslation());
 
   58                foreach ($translation->getPluralTranslation() as $k => $v) {
 
   68        return implode(
"\n", $lines);
 
   80        $lines = explode(
"\n", $string);
 
   81        $last = count($lines) - 1;
 
   83        foreach ($lines as $k => $line) {
 
  105        if (count($newLines) === 1) {
 
  106            $lines[] = 
$name.
' '.$newLines[0];
 
  108            $lines[] = 
$name.
' ""';
 
  110            foreach ($newLines as $line) {
 
An exception for terminatinating execution or to throw for unit testing.
static convertString($value)
Convert a string to its PO representation.
static toString(Translations $translations)
{@parentDoc}.
static multilineQuote($string)
Escapes and adds double quotes to a string.
static addLines(array &$lines, $name, $value)
Add one or more lines depending whether the string is multiline or not.
Class to manage a collection of translations.
getHeaders()
Returns all header for this translations.