[Translation][fallback] add missing resources in parent catalogues.
This commit is contained in:
parent
f37ac131e1
commit
27c91e514e
@ -178,6 +178,10 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
|
||||
if ($c->getLocale() === $catalogue->getLocale()) {
|
||||
throw new \LogicException(sprintf('Circular reference detected when adding a fallback catalogue for locale "%s".', $catalogue->getLocale()));
|
||||
}
|
||||
|
||||
foreach ($catalogue->getResources() as $resource) {
|
||||
$c->addResource($resource);
|
||||
}
|
||||
} while ($c = $c->parent);
|
||||
|
||||
$catalogue->parent = $this;
|
||||
|
@ -110,18 +110,25 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
$r1 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
|
||||
$r1->expects($this->any())->method('__toString')->will($this->returnValue('r1'));
|
||||
|
||||
$catalogue = new MessageCatalogue('en_US', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
|
||||
$r2 = $this->getMock('Symfony\Component\Config\Resource\ResourceInterface');
|
||||
$r2->expects($this->any())->method('__toString')->will($this->returnValue('r2'));
|
||||
|
||||
$catalogue = new MessageCatalogue('fr_FR', array('domain1' => array('foo' => 'foo'), 'domain2' => array('bar' => 'bar')));
|
||||
$catalogue->addResource($r);
|
||||
|
||||
$catalogue1 = new MessageCatalogue('en', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
|
||||
$catalogue1 = new MessageCatalogue('fr', array('domain1' => array('foo' => 'bar', 'foo1' => 'foo1')));
|
||||
$catalogue1->addResource($r1);
|
||||
|
||||
$catalogue2 = new MessageCatalogue('en');
|
||||
$catalogue2->addResource($r2);
|
||||
|
||||
$catalogue->addFallbackCatalogue($catalogue1);
|
||||
$catalogue1->addFallbackCatalogue($catalogue2);
|
||||
|
||||
$this->assertEquals('foo', $catalogue->get('foo', 'domain1'));
|
||||
$this->assertEquals('foo1', $catalogue->get('foo1', 'domain1'));
|
||||
|
||||
$this->assertEquals(array($r, $r1), $catalogue->getResources());
|
||||
$this->assertEquals(array($r, $r1, $r2), $catalogue->getResources());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user