protected function _prepareForWrite(array $item) {
		$filter = function ($value) use (&$filter) {
			if (is_array($value)) {
				return array_map($filter, $value);
			}
			$value = strtr($value, ["\\'" => "'", "\\\\" => "\\", "\r\n" => "\n"]);
			$value = addcslashes($value, "\0..\37\\\"");
			return $value;
		};
		$fields = ['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);
	}
protected function _prepareForWrite(array $item) {
		$filter = function ($value) use (&$filter) {
			if (is_array($value)) {
				return array_map($filter, $value);
			}
			$value = strtr($value, ["\\'" => "'", "\\\\" => "\\", "\r\n" => "\n"]);
			$value = addcslashes($value, "\0..\37\\\"");
			return $value;
		};
		$fields = ['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);
	}
protected function _prepareForWrite ( array $ item ) { $ filter = function ( $ value ) use ( & $ filter ) { if ( is_array ( $ value ) ) { return array_map ( $ filter , $ value ) ; } $ value = strtr ( $ value , [ "\\'" => "'" , "\\\\" => "\\" , "\r\n" => "\n" ] ) ; $ value = addcslashes ( $ value , "\0..\37\\\"" ) ; return $ value ; } ; $ fields = [ '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 ) ; }
Prepares an item before it is being written and escapes fields.

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.

@link http://www.asciitable.com
@see lithium\g11n\catalog\Adapter::_prepareForWrite()
@param array $item
@return array
Prepares an item before it is being written and escapes fields .