merged branch hilobok/ticket_7715 (PR #7819)
This PR was submitted for the master branch but it was merged into the 2.2 branch instead (closes #7819). Discussion ---------- [Translator] Added reloading of fallback catalogues when calling addResource() (#7715) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7715 | License | MIT | Doc PR | Commits ------- 4f0b063 [Translator] Reset all catalogues when adding resource to fallback locale (#7715, #7819) 5544f36 [Translator] Added reloading of fallback catalogues when calling addResource() (#7715)
This commit is contained in:
commit
609b5ff08c
@ -67,6 +67,20 @@ class TranslatorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
public function testAddResourceAfterTrans()
|
||||
{
|
||||
$translator = new Translator('fr', new MessageSelector());
|
||||
$translator->addLoader('array', new ArrayLoader());
|
||||
|
||||
$translator->setFallbackLocales(array('en'));
|
||||
|
||||
$translator->addResource('array', array('foo' => 'foofoo'), 'en');
|
||||
$this->assertEquals('foofoo', $translator->trans('foo'));
|
||||
|
||||
$translator->addResource('array', array('bar' => 'foobar'), 'en');
|
||||
$this->assertEquals('foobar', $translator->trans('bar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getTransFileTests
|
||||
* @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException
|
||||
|
@ -94,7 +94,11 @@ class Translator implements TranslatorInterface
|
||||
{
|
||||
$this->resources[$locale][] = array($format, $resource, $domain);
|
||||
|
||||
unset($this->catalogues[$locale]);
|
||||
if(in_array($locale, $this->fallbackLocales)) {
|
||||
$this->catalogues = array();
|
||||
} else {
|
||||
unset($this->catalogues[$locale]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user