function testExtractStringsKarelia() { $s = DIRECTORY_SEPARATOR; $html = file_get_contents(dirname(__FILE__) . $s . 'testsites' . $s . 'site3' . $s . 'index.html'); $tr = new WebLite_HTML_Translator(); $extracted = $tr->extractStrings($html); //echo $extracted;exit; $expected = file_get_contents(dirname(__FILE__) . $s . 'testsites' . $s . 'site3' . $s . 'index.extracted.html'); $this->assertEquals(trim($expected), trim($extracted)); $expected = file_get_contents(dirname(__FILE__) . $s . 'testsites' . $s . 'site3' . $s . 'index.strings.json'); $expected = json_decode($expected, true); $this->assertEquals($expected, $tr->strings); }
public static function test() { //$dom = file_get_html('http://www.mozartschool.com/register.htm'); //$text = $dom->find('text'); //foreach ($text as $tx){ // if ( !trim($tx->innertext) ) continue; // echo $tx->tag."\n".$tx->parent->tag."\n"; // echo $tx->innertext."\n\n"; //} //exit; $translator = new WebLite_HTML_Translator(); $translator->translate(file_get_contents('http://dev.translate.weblite.ca/index.html')); print_r($translator->strings); //print_r($translator->translate(file_get_contents('http://en.wikipedia.org/wiki/Richard_Marx'))); //$translator->translateNode($dom->find('html',0)); //echo $dom->save(); //print_r($translator->strings); }