function PoItem::formatItem

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::formatItem()
  2. 8.9.x core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::formatItem()
  3. 11.x core/lib/Drupal/Component/Gettext/PoItem.php \Drupal\Component\Gettext\PoItem::formatItem()

Format the POItem as a string.

1 call to PoItem::formatItem()
PoItem::__toString in core/lib/Drupal/Component/Gettext/PoItem.php
Output the PoItem as a string.

File

core/lib/Drupal/Component/Gettext/PoItem.php, line 220

Class

PoItem
PoItem handles one translation.

Namespace

Drupal\Component\Gettext

Code

private function formatItem() {
  $output = '';
  // Format string context.
  if (!empty($this->context)) {
    $output .= 'msgctxt ' . $this->formatString($this->context);
  }
  // Format translation.
  if ($this->plural) {
    $output .= $this->formatPlural();
  }
  else {
    $output .= $this->formatSingular();
  }
  // Add one empty line to separate the translations.
  $output .= "\n";
  return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.