本文整理匯總了PHP中JMS\TranslationBundle\Model\Message::setLocaleString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Message::setLocaleString方法的具體用法?PHP Message::setLocaleString怎麽用?PHP Message::setLocaleString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類JMS\TranslationBundle\Model\Message
的用法示例。
在下文中一共展示了Message::setLocaleString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testMergeExisting
public function testMergeExisting()
{
$scannedMessage = new XliffMessage('foo');
$scannedMessage->setDesc('foo');
$existingMessage = new XliffMessage('foo');
$existingMessage->setLocaleString('bar');
$existingMessage->addSource(new FileSource('bar'));
$existingMessage->setApproved(true);
$existingMessage->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage2 = new Message('foo');
$existingMessage2->setLocaleString('bar');
$existingMessage2->setNew(false);
$existingMessage2->addSource(new FileSource('bar'));
$scannedMessage1 = clone $scannedMessage;
$existingMessage1 = clone $existingMessage;
$scannedMessage1->mergeExisting($existingMessage1);
$this->assertEquals('foo', $scannedMessage1->getDesc());
$this->assertEquals('bar', $scannedMessage1->getLocaleString());
$this->assertFalse($scannedMessage1->isNew());
$this->assertEquals(array(), $scannedMessage1->getSources());
$this->assertFalse($scannedMessage1->isApproved());
$this->assertEquals(XliffMessage::STATE_NONE, $scannedMessage1->getState());
$scannedMessage2 = clone $scannedMessage;
$scannedMessage2->setApproved(true);
$scannedMessage2->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage2 = clone $existingMessage;
$existingMessage2->setDesc('bar');
$existingMessage2->setApproved(false);
$existingMessage2->setState(XliffMessage::STATE_NONE);
$scannedMessage2->mergeExisting($existingMessage2);
$this->assertEquals('foo', $scannedMessage2->getDesc());
$this->assertTrue($scannedMessage2->isApproved());
$this->assertEquals(XliffMessage::STATE_TRANSLATED, $scannedMessage2->getState());
$scannedMessage3 = clone $scannedMessage;
$existingMessage3 = clone $existingMessage1;
$scannedMessage3->mergeExisting($existingMessage3);
$this->assertEquals('foo', $scannedMessage3->getDesc());
$this->assertEquals('bar', $scannedMessage3->getLocaleString());
$this->assertFalse($scannedMessage3->isNew());
$this->assertEquals(array(), $scannedMessage3->getSources());
$this->assertFalse($scannedMessage3->isApproved());
$this->assertEquals(XliffMessage::STATE_NONE, $scannedMessage3->getState());
$scannedMessage4 = clone $scannedMessage;
$scannedMessage4->setApproved(true);
$scannedMessage4->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage4 = clone $existingMessage1;
$existingMessage4->setDesc('bar');
$scannedMessage4->mergeExisting($existingMessage4);
$this->assertEquals('foo', $scannedMessage4->getDesc());
$this->assertTrue($scannedMessage4->isApproved());
$this->assertEquals(XliffMessage::STATE_TRANSLATED, $scannedMessage4->getState());
}
示例2: testMergeExisting
public function testMergeExisting()
{
$message = new Message('foo');
$message->setDesc('bar');
$existingMessage = new Message('foo');
$existingMessage->setLocaleString('foobar');
$existingMessage->setNew(false);
$existingMessage->addSource(new FileSource('foo/bar'));
$message->mergeExisting($existingMessage);
$this->assertEquals('bar', $message->getDesc());
$this->assertEquals('foobar', $message->getLocaleString());
$this->assertFalse($message->isNew());
$this->assertEquals(array(), $message->getSources());
}
示例3: createTranslation
/**
* @param string $file
* @param string $format
* @param string $domain
* @param string $locale
* @param string $key
* @param string $trans
*/
public function createTranslation($file, $format, $domain, $locale, $key, $trans)
{
$catalogue = $this->loader->loadFile($file, $format, $locale, $domain);
$message = new Message($key, $domain);
$message->setLocaleString($trans)->setNew(false);
$catalogue->add($message);
$this->writer->write($catalogue, $domain, $file, $format);
}