function _pocheck($po) { global $DBInfo; include_once 'lib/Gettext/PO.php'; $myPO = new TGettext_PO(); if (true !== ($e = $myPO->load($po, 0))) { print "Fail to load po file.\n"; return $e; } $myMO = $myPO->toMO(); $vartmp_dir = $DBInfo->vartmp_dir; $tmp = tempnam($vartmp_dir, "GETTEXT"); #$tmp=$vartmp_dir."/GETTEXT.mo"; if (true !== ($e = $myMO->save($tmp))) { print "Fail to compile mo file.\n"; return $e; } unset($myPO, $myMO); chmod($tmp, 0644); //unlink($tmp); return true; }
/** * poFile2moFile * * That's a simple fake of the 'msgfmt' console command. It reads the * contents of a GNU PO file and saves them to a GNU MO file. * * @static * @access public * @return mixed Returns true on success or PEAR_Error on failure. * @param string $pofile path to GNU PO file * @param string $mofile path to GNU MO file */ function poFile2moFile($pofile, $mofile) { if (!is_file($pofile)) { throw new Exception("File {$pofile} doesn't exist."); } include_once dirname(__FILE__) . '/PO.php'; $PO = new TGettext_PO($pofile); if (true !== ($e = $PO->load())) { return $e; } $MO = $PO->toMO(); if (true !== ($e = $MO->save($mofile))) { return $e; } unset($PO, $MO); return true; }