/** * Write POFile::$msgids into $file_path. * * @return true|string True on success, string with error on failure */ function write_evo_trans($file_path, $locale) { $fp = fopen($file_path, 'w+'); if (!$fp) { return "Could not open {$file_path} for writing!"; } fwrite($fp, "<?php\n"); fwrite($fp, "/*\n"); fwrite($fp, " * Global lang file\n"); fwrite($fp, " * This file was generated automatically from messages.po\n"); fwrite($fp, " */\n"); fwrite($fp, "if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );"); fwrite($fp, "\n\n"); fwrite($fp, '$trans[\'' . $locale . "'] = array(\n"); // Write meta/format info: $charset = 'utf-8'; // default if (isset($this->msgids[''])) { if (preg_match('~\\\\nContent-Type: text/plain; charset=(.*?);?\\\\n~', $this->msgids['']['trans'], $match)) { $charset = strtolower($match[1]); } } fwrite($fp, "'__meta__' => array('format_version'=>1, 'charset'=>'{$charset}'),\n"); foreach ($this->msgids as $msgid => $msginfo) { $msgstr = $msginfo['trans']; fwrite($fp, POFile::quote($msgid) . ' => ' . POFile::quote($msgstr) . ",\n"); } fwrite($fp, "\n);\n?>"); fclose($fp); return true; }