You are here

function _locale_export_string in Drupal 7

Same name and namespace in other branches
  1. 6 includes/locale.inc \_locale_export_string()

Print out a string on multiple lines

Related topics

1 call to _locale_export_string()
_locale_export_po_generate in includes/locale.inc
Generates the PO(T) file contents for given strings.

File

includes/locale.inc, line 1805
Administration functions for locale.module.

Code

function _locale_export_string($str) {
  $stri = addcslashes($str, "\0..\37\\\"");
  $parts = array();

  // Cut text into several lines
  while ($stri != "") {
    $i = strpos($stri, "\\n");
    if ($i === FALSE) {
      $curstr = $stri;
      $stri = "";
    }
    else {
      $curstr = substr($stri, 0, $i + 2);
      $stri = substr($stri, $i + 2);
    }
    $curparts = explode("\n", _locale_export_wrap($curstr, 70));
    $parts = array_merge($parts, $curparts);
  }

  // Multiline string
  if (count($parts) > 1) {
    return "\"\"\n\"" . implode("\"\n\"", $parts) . "\"\n";
  }
  elseif (count($parts) == 1) {
    return "\"{$parts[0]}\"\n";
  }
  else {
    return "\"\"\n";
  }
}