예제 #1
0
 /**
  * Test the parsing.
  *
  * @return void
  */
 public function testParseShortArray()
 {
     $file = new ContaoFile($this->getFixturesPath() . 'contao-parse3-short-array.php');
     $this->assertEquals(5, count($file->getKeys()));
     $this->assertEquals('a-a-1', $file->getValue('a.a.0'));
     $this->assertEquals('a-a-2', $file->getValue('a.a.1'));
     $this->assertEquals('a-b-1', $file->getValue('a.b.0'));
     $this->assertEquals('a-b-2', $file->getValue('a.b.1'));
     $this->assertEquals('a-b-c', $file->getValue('a.b.c'));
 }
 /**
  * Convert the source file to the destination file.
  *
  * @param OutputInterface $output An OutputInterface instance.
  *
  * @param ContaoFile      $src    The source Contao file.
  *
  * @param XLiffFile       $dst    The destination XLIFF file.
  *
  * @param ContaoFile      $base   The base Contao file.
  *
  * @return void
  */
 protected function convert(OutputInterface $output, ContaoFile $src, XLiffFile $dst, ContaoFile $base)
 {
     $baseKeys = $base->getKeys();
     foreach ($baseKeys as $key) {
         if (!($basVal = $base->getValue($key))) {
             $dst->remove($key);
             continue;
         }
         $dst->setSource($key, $basVal);
         if (($value = $src->getValue($key)) !== null) {
             $dst->setTarget($key, $value);
         }
     }
     foreach ($dst->getKeys() as $key) {
         if (!in_array($key, $baseKeys)) {
             $this->writelnVerbose($output, sprintf('Language key <info>%s</info> is not present in the source. Removing it.', $key));
             $dst->remove($key);
         }
     }
 }