本文整理汇总了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);
}