Example #1
0
 /**
  * @param $child
  * @param $xmlNS
  * @param $about
  * @param $tus
  * @return array
  */
 protected function processUnit($child, $xmlNS, $about, $tus)
 {
     if ($child->hasAttributeNS($xmlNS, 'lang')) {
         $sourceLanguage = 'en-US';
         $targetLanguage = $child->getAttributeNodeNS($xmlNS, 'lang')->value;
         $source = $child->nodeValue;
         $target = $child->nodeValue;
         $tu = new tao_helpers_translation_RDFTranslationUnit();
         $tu->setSource($source);
         $tu->setTarget($target);
         $tu->setSourceLanguage($sourceLanguage);
         $tu->setTargetLanguage($targetLanguage);
         $tu->setSubject($about);
         $tu->setPredicate($child->namespaceURI . $child->localName);
         $tus[] = $tu;
         return $tus;
     }
     return $tus;
 }
 public function testRDFTranslationWriting()
 {
     $rdfFilePath = tempnam('/tmp', self::TEMP_RDF);
     $rdfFile = new tao_helpers_translation_RDFTranslationFile('en-US', 'multiple');
     $rdfFile->setBase('http://www.tao.lu/Ontologies/TAO.rdf#');
     $writer = new tao_helpers_translation_RDFFileWriter($rdfFilePath, $rdfFile);
     $tu1 = new tao_helpers_translation_RDFTranslationUnit("This is a test");
     $tu1->setSourceLanguage('en-US');
     $tu1->setTargetLanguage('fr-FR');
     $tu1->setSubject('http://www.tao.lu#target1');
     $tu1->setPredicate('http://www.w3.org/2000/01/rdf-schema#label');
     $rdfFile->addTranslationUnit($tu1);
     $writer->write();
     $this->assertTrue(file_exists($rdfFilePath));
     unlink($rdfFilePath);
 }