function PoItem::formatPlural

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

Formats a plural translation.

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

File

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

Class

PoItem
PoItem handles one translation.

Namespace

Drupal\Component\Gettext

Code

private function formatPlural() {
    $output = '';
    // Format source strings.
    $output .= 'msgid ' . $this->formatString($this->source[0]);
    $output .= 'msgid_plural ' . $this->formatString($this->source[1]);
    foreach ($this->translation as $i => $trans) {
        if (isset($this->translation[$i])) {
            $output .= 'msgstr[' . $i . '] ' . $this->formatString($trans);
        }
        else {
            $output .= 'msgstr[' . $i . '] ""' . "\n";
        }
    }
    return $output;
}

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