public function testMultipleManfiestExtraction()
 {
     $taoStructurePaths = array(dirname(__FILE__) . self::GROUPS_MANIFEST . '/structures.xml', dirname(__FILE__) . self::ITEMS_MANIFEST . '/structures.xml');
     $extractor = new tao_helpers_translation_StructureExtractor($taoStructurePaths);
     $extractor->extract();
     $tus = $extractor->getTranslationUnits();
     $this->assertEquals(26, count($tus));
     $this->assertEquals('Search', $tus[6]->getSource());
     $this->assertEquals('Delete', $tus[9]->getSource());
     $this->assertEquals('Items', $tus[17]->getSource());
     $this->assertEquals('Preview', $tus[24]->getSource());
 }
Esempio n. 2
0
 /**
  * Add translations as translation units found in a structure.xml manifest
  * a given PO file.
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param tao_helpers_translation_POFile $poFile
  * @throws Exception
  * @return void
  */
 public function addManifestsTranslations(tao_helpers_translation_POFile $poFile)
 {
     $this->outVerbose("Adding all manifests messages to extension '" . $this->options['extension'] . "'");
     $rootDir = dirname(__FILE__) . '/../../';
     $directories = scandir($rootDir);
     $exceptions = array('generis', 'tao', '.*');
     if (false === $directories) {
         $this->err("The TAO root directory is not readable. Please check permissions on this directory.", true);
     } else {
         foreach ($directories as $dir) {
             if (is_dir($rootDir . $dir) && !in_array($dir, $exceptions)) {
                 // Maybe it should be read.
                 if (in_array('.*', $exceptions) && $dir[0] == '.') {
                     continue;
                 } else {
                     // Is this a TAO extension ?
                     $file = MenuService::getStructuresFilePath($this->options['extension']);
                     if (!is_null($file)) {
                         $structureExtractor = new tao_helpers_translation_StructureExtractor(array($file));
                         $structureExtractor->extract();
                         $poFile->addTranslationUnits($structureExtractor->getTranslationUnits());
                         $this->outVerbose("Manifest of extension '" . $dir . "' added to extension '" . $this->options['extension'] . "'");
                     }
                 }
             }
         }
     }
 }