potx.locale.inc in Translation template extractor 8
Contains locale functions that were removed in Drupal 8.
File
potx.locale.incView source
<?php
/**
* @file
* Contains locale functions that were removed in Drupal 8.
*/
/**
* Print out a string on multiple lines.
*/
function _locale_export_string($str) {
$stri = addcslashes($str, "\0..\37\\\"");
$parts = [];
// 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";
}
}
/**
* Custom word wrapping for Portable Object (Template) files.
*/
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);
}
/**
* Removes plural index information from a string.
*/
function _locale_export_remove_plural($entry) {
return preg_replace('/(@count)\\[[0-9]\\]/', '\\1', $entry);
}
Functions
Name | Description |
---|---|
_locale_export_remove_plural | Removes plural index information from a string. |
_locale_export_string | Print out a string on multiple lines. |
_locale_export_wrap | Custom word wrapping for Portable Object (Template) files. |