You are here

public function PoDatabaseWriter::writeItem in Localization update 7.2

Implements PoWriterInterface::writeItem().

Overrides PoWriterInterface::writeItem

1 call to PoDatabaseWriter::writeItem()
PoDatabaseWriter::writeItems in includes/locale/PoDatabaseWriter.php
Implements PoWriterInterface::writeItems().

File

includes/locale/PoDatabaseWriter.php, line 197
Definition of PoDatabaseWriter.

Class

PoDatabaseWriter
Gettext PO writer working with the locale module database.

Code

public function writeItem(PoItem $item) {
  if ($item
    ->isPlural()) {
    $sources = $item
      ->getSource();
    $translations = $item
      ->getTranslation();

    // Build additional source strings for plurals.
    $entries = array_keys($translations);
    for ($i = 3; $i <= count($entries); $i++) {
      $sources[] = $sources[1];
    }
    $translations = array_map('_locale_import_append_plural', $translations, $entries);
    $sources = array_map('_locale_import_append_plural', $sources, $entries);
    $plid = 0;
    foreach ($entries as $index) {
      $item
        ->setSource($sources[$index]);
      $item
        ->setTranslation($translations[$index]);
      $plid = $this
        ->importString($item, $plid, $index);
    }
  }
  else {
    $this
      ->importString($item);
  }
}