PoItem example

$comments = '';
    if (isset($value['#'])) {
      $comments = $this->shortenComments($value['#']);
    }

    if (is_array($value['msgstr'])) {
      // Sort plural variants by their form index.       ksort($value['msgstr']);
      $plural = TRUE;
    }

    $item = new PoItem();
    $item->setContext($value['msgctxt'] ?? '');
    $item->setSource($value['msgid']);
    $item->setTranslation($value['msgstr']);
    $item->setPlural($plural);
    $item->setComment($comments);
    $item->setLangcode($this->langcode);

    $this->lastItem = $item;

    $this->context = 'COMMENT';
  }

  
$this->result = $this->loadStrings();
    }
    return array_shift($this->result);
  }

  /** * {@inheritdoc} */
  public function readItem() {
    if ($string = $this->readString()) {
      $values = (array) $string;
      $po_item = new PoItem();
      $po_item->setFromArray($values);
      return $po_item;
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.