lithium\g11n\catalog\adapter\Gettext::_prepareForWrite PHP Method

_prepareForWrite() protected method

All characters from \000 to \037 (this includes new line and tab characters) as well as the backslash (\) and the double quote (") are escaped. Literal Windows CRLFs (\r\n) are converted to LFs (\n) to improve cross platform compatibility. Escaped single quotes (') are unescaped as they should not need to be. Double escaped characters are maintained and not escaped once again.
See also: lithium\g11n\catalog\Adapter::_prepareForWrite()
protected _prepareForWrite ( array $item ) : array
$item array
return array
    protected function _prepareForWrite(array $item)
    {
        $filter = function ($value) use(&$filter) {
            if (is_array($value)) {
                return array_map($filter, $value);
            }
            $value = strtr($value, array("\\'" => "'", "\\\\" => "\\", "\r\n" => "\n"));
            $value = addcslashes($value, "..\\\"");
            return $value;
        };
        $fields = array('id', 'ids', 'translated', 'context');
        foreach ($fields as $field) {
            if (isset($item[$field])) {
                $item[$field] = $filter($item[$field]);
            }
        }
        if (!isset($item['ids']['singular'])) {
            $item['ids']['singular'] = $item['id'];
        }
        $path = Libraries::get(true, 'path');
        if (isset($item['occurrences'])) {
            foreach ($item['occurrences'] as &$occurrence) {
                $occurrence['file'] = str_replace($path, '', $occurrence['file']);
            }
        }
        return parent::_prepareForWrite($item);
    }