public function testParseFileEnglish() { $obj = new _DotLangParser(); /* Load file as English. Some info (comments, bound tags) * are extracted only for English */ $test_file = TEST_FILES . 'dotlang/toto.lang'; $dotlang_data = $obj->parseFile($test_file, true); // Check comments $this->integer(count($dotlang_data['comments']))->isEqualTo(2); $this->string($dotlang_data['comments']['Browser'][0])->isEqualTo('I am a comment'); // Check duplicates $this->boolean(in_array('Hello', $dotlang_data['duplicates']))->isTrue(); // Check bound tags $this->integer(count($dotlang_data['tag_bindings']))->isEqualTo(1); $this->string($dotlang_data['tag_bindings']['String with tag'])->isEqualTo('bound tag'); // Check character limits $this->integer(count($dotlang_data['max_lengths']))->isEqualTo(2); $this->integer($dotlang_data['max_lengths']['Save file'])->isEqualTo(12); $this->integer($dotlang_data['max_lengths']['Save file wrong'])->isEqualTo(0); }
public function testImportLocalPoFile() { $po_filepath = TEST_FILES . 'gettext/test.po'; $lang_filepath = TEST_FILES . 'gettext/test.lang'; $obj = new _GetTextManager(); $locale_data = _DotLangParser::parseFile($lang_filepath, false); $po_import = $obj->importLocalPoFile($po_filepath, $locale_data, false); // I should have imported data $this->boolean($po_import['imported'])->isTrue(); // I should have one error $this->integer(count($po_import['errors']))->isEqualTo(1); // Test one translated string $this->string($po_import['strings']['Innovating <span>for you</span>'])->isEqualTo('¡Inovando <span>para ti!</span>'); // Test one translated string in both lang and po file (second has precedence) $this->string($po_import['strings']['Fast, flexible, <span>secure</span>'])->isEqualTo('Rápido, flexible, seguro'); // Empty translation in .po file, existing in .lang file $this->string($po_import['strings']['Empty'])->isEqualTo('test'); // Test one identical string $this->string($po_import['strings']['Download'])->isEqualTo('Download {ok}'); // Test one translation starting with ; (should be ignored) $this->string($po_import['strings']['Download test'])->isEqualTo('Download test'); }