public function testGetSetMessage() { $catalogue = new MessageCatalogue('en', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar'))); $catalogue->setMessage('foo1', 'foo1', 'domain1'); $this->assertEquals('foo', $catalogue->getMessage('foo', 'domain1')); $this->assertEquals('foo1', $catalogue->getMessage('foo1', 'domain1')); }
/** * {@inheritdoc} */ public function load($resource, $locale, $domain = 'messages') { $xml = $this->parseFile($resource); $xml->registerXPathNamespace('xliff', 'urn:oasis:names:tc:xliff:document:1.2'); $catalogue = new MessageCatalogue($locale); foreach ($xml->xpath('//xliff:trans-unit') as $translation) { $catalogue->setMessage((string) $translation->source, (string) $translation->target, $domain); } $catalogue->addResource(new FileResource($resource)); return $catalogue; }