Exemplo n.º 1
0
    public function testSpaces_1()
    {
        $source_seg = <<<SRC
<g id="pt2">WASHINGTON </g><g id="pt3">— The Treasury Department and Internal Revenue Service today requested public comment on issues relating to the shared responsibility provisions included in the Affordable Care Act that will apply to certain employers starting in 2014.</g>
SRC;
        $target_seg = <<<TRG
<g id="pt2"> WASHINGTON </g><g id="pt3">- Il Dipartimento del Tesoro e Internal Revenue Service di oggi hanno chiesto un commento pubblico sulle questioni relative alle disposizioni di responsabilità condivise incluse nel Affordable Care Act che verranno applicate a certi datori di lavoro a partire dal 2014. </g>
TRG;
        $source_seg = CatUtils::view2rawxliff($source_seg);
        $target_seg = CatUtils::view2rawxliff($target_seg);
        $check = new QA($source_seg, $target_seg);
        $check->performConsistencyCheck();
        $notices = $check->getNotices();
        $warnings = $check->getWarnings();
        $errors = $check->getErrors();
        $this->assertFalse($check->thereAreErrors());
        $this->assertFalse($check->thereAreWarnings());
        $this->assertTrue($check->thereAreNotices());
        $this->assertEquals(count($notices), 2);
        $this->assertEquals(1100, $notices[0]->outcome);
        $this->assertEquals(count($warnings), 1);
        $this->assertEquals(0, $warnings[0]->outcome);
        $this->assertEquals(count($errors), 1);
        $this->assertEquals(0, $errors[0]->outcome);
        $normalized = $check->getTrgNormalized();
        //" 1 " -> 20 31 20
        $this->assertEquals('<g id="pt2"> WASHINGTON </g><g id="pt3">- Il Dipartimento del Tesoro e Internal Revenue Service di oggi hanno chiesto un commento pubblico sulle questioni relative alle disposizioni di responsabilità condivise incluse nel Affordable Care Act che verranno applicate a certi datori di lavoro a partire dal 2014. </g>', $normalized);
    }
 protected function prepareSegment($seg, $trans_unit_translation = "")
 {
     $end_tags = "";
     //We don't need transform/sanitize from wiew to xliff because the values comes from Database
     //QA non sense for source/source check, until source can be changed. For now SKIP
     if (is_null($seg['translation']) || $seg['translation'] == '') {
         $translation = $seg['segment'];
     } else {
         $translation = $seg['translation'];
         if (empty($seg['locked'])) {
             //consistency check
             $check = new QA($seg['segment'], $translation);
             $check->performTagCheckOnly();
             if ($check->thereAreErrors()) {
                 $translation = '|||UNTRANSLATED_CONTENT_START|||' . $seg['segment'] . '|||UNTRANSLATED_CONTENT_END|||';
                 Log::doLog("tag mismatch on\n" . print_r($seg, true) . "\n(because of: " . print_r($check->getErrors(), true) . ")");
             }
         }
     }
     if ($seg['mrk_id'] !== null) {
         $translation = "<mrk mid=\"" . $seg['mrk_id'] . "\" mtype=\"seg\">" . $seg['mrk_prev_tags'] . $translation . $seg['mrk_succ_tags'] . "</mrk>";
     }
     $trans_unit_translation .= $seg['prev_tags'] . $translation . $end_tags . $seg['succ_tags'];
     return $trans_unit_translation;
 }