function _locale_export_wrap in Translation template extractor 8
Custom word wrapping for Portable Object (Template) files.
1 call to _locale_export_wrap()
- _locale_export_string in ./
potx.locale.inc - Print out a string on multiple lines.
File
- ./
potx.locale.inc, line 47 - Contains locale functions that were removed in Drupal 8.
Code
function _locale_export_wrap($str, $len) {
$words = explode(' ', $str);
$return = [];
$cur = "";
$nstr = 1;
while (count($words)) {
$word = array_shift($words);
if ($nstr) {
$cur = $word;
$nstr = 0;
}
elseif (strlen("{$cur} {$word}") > $len) {
$return[] = $cur . " ";
$cur = $word;
}
else {
$cur = "{$cur} {$word}";
}
}
$return[] = $cur;
return implode("\n", $return);
}