private function PoItem::formatString in Localization update 7.2
Formats a string for output on multiple lines.
Parameters
string $string: A string.
Return value
string Gettext formatted multi-line string.
3 calls to PoItem::formatString()
- PoItem::formatItem in includes/gettext/ PoItem.php 
- Format the POItem as a string.
- PoItem::formatPlural in includes/gettext/ PoItem.php 
- Formats a plural translation.
- PoItem::formatSingular in includes/gettext/ PoItem.php 
- Formats a singular translation.
File
- includes/gettext/ PoItem.php, line 309 
- Definition of Drupal\Component\Gettext\PoItem.
Class
- PoItem
- PoItem handles one translation.
Code
private function formatString($string) {
  // Escape characters for processing.
  $string = addcslashes($string, "\0..\37\\\"");
  // Always include a line break after the explicit \n line breaks from
  // the source string. Otherwise wrap at 70 chars to accommodate the extra
  // format overhead too.
  $parts = explode("\n", wordwrap(str_replace('\\n', "\\n\n", $string), 70, " \n"));
  // Multiline string should be exported starting with a "" and newline to
  // have all lines aligned on the same column.
  if (count($parts) > 1) {
    return "\"\"\n\"" . implode("\"\n\"", $parts) . "\"\n";
  }
  else {
    return "\"{$parts[0]}\"\n";
  }
}