* @package tao */ class tao_helpers_translation_PHPFileWriter extends tao_helpers_translation_TranslationFileWriter { // --- ASSOCIATIONS --- // --- ATTRIBUTES --- // --- OPERATIONS --- /** * Writes the TranslationFile as a PHP compiled file. * * @access public * @author Jerome Bogaerts, * @return mixed */ public function write() { $tf = $this->getTranslationFile(); $buffer = "getTranslationUnits() as $tu) { // Prevent empty messages. if ($tu->getSource() != '' && $tu->getTarget() != '') { $escapes = ["\\", '$', '"', "\n", "\t", "\v", "\r", "\f"]; $replace = ["\\\\", '\\$', '\\"', "\\n", "\\t", "\\v", "\\r", "\\f"]; $source = str_replace($escapes, $replace, $tu->getSource()); $target = str_replace($escapes, $replace, $tu->getTarget()); $buffer .= '$GLOBALS[\'__l10n\']["' . $source . '"]="' . $target . '";' . "\n"; } } $buffer .= "\n?>"; file_put_contents($this->getFilePath(), $buffer); } }