Sepia\PoParser::writeFile PHP Method

writeFile() public method

Writes entries to a po file
public writeFile ( string $filepath ) : boolean
$filepath string
return boolean
    public function writeFile($filepath)
    {
        $output = $this->compile();
        $result = file_put_contents($filepath, $output);
        if ($result === false) {
            throw new \Exception('Could not write into file ' . htmlspecialchars($filepath));
        }
        return true;
    }

Usage Example

Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $inFile = new FileHandler($input->getArgument('from'));
     $outFileLocation = $input->getArgument('to');
     $poParser = new PoParser($inFile);
     $messages = $poParser->parse($inFile);
     foreach ($messages as $msgid => $message) {
         $message = $this->translateMessage($message);
         $poParser->setEntry($msgid, $message, false);
     }
     $poParser->writeFile($outFileLocation);
 }