/** * Tests whether a translation exists in db file * * @param UnitTester $I * @author Serghei Iakovlev <*****@*****.**> * @since 2016-01-16 */ public function exists(UnitTester $I) { $I->wantTo("check translation exists in db file by using Gettext::exists"); $translator = new Gettext(['locale' => 'en_US.utf8', 'defaultDomain' => 'messages', 'directory' => PATH_DATA . 'translation/gettext', 'category' => LC_MESSAGES]); $I->assertFalse($translator->exists('更多的中国')); $I->assertFalse($translator->exists('Some non-existent string string')); $I->assertTrue($translator->exists('你好!')); }
public function testGettextTranslate() { $t = new Gettext(array('locale' => 'en_US.utf8', 'defaultDomain' => 'messages', 'directory' => __DIR__ . DIRECTORY_SEPARATOR . 'locale')); $this->assertTrue($t->exists('你好!')); $this->assertFalse($t->exists('更多的中国')); $this->assertEquals($t->query('你好!'), 'Hello!'); $this->assertEquals($t['你好!'], 'Hello!'); $actual = $t->_('你好 %name%!', array('name' => 'Phalcon')); $this->assertEquals($actual, 'Hello Phalcon!'); }