Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Symfony/Component/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ public function transChoice($id, $number, array $parameters = array(), $domain =
protected function loadCatalogue($locale)
{
$this->catalogues[$locale] = new MessageCatalogue($locale);
if (!isset($this->resources[$locale])) {
return;
}

foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
if (isset($this->resources[$locale])) {

foreach ($this->resources[$locale] as $resource) {
if (!isset($this->loaders[$resource[0]])) {
throw new \RuntimeException(sprintf('The "%s" translation loader is not registered.', $resource[0]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}
$this->catalogues[$locale]->addCatalogue($this->loaders[$resource[0]]->load($resource[1], $locale, $resource[2]));
}

$this->optimizeCatalogue($locale);
Expand Down
4 changes: 3 additions & 1 deletion tests/Symfony/Tests/Component/Translation/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ public function testSetFallbackLocale()

public function testTransWithFallbackLocale()
{
$translator = new Translator('en_US', new MessageSelector());
$translator = new Translator('fr_FR', new MessageSelector());
$translator->addLoader('array', new ArrayLoader());
$translator->addResource('array', array('foo' => 'foofoo'), 'en_US');
$translator->addResource('array', array('bar' => 'foobar'), 'en');

$translator->setFallbackLocale('en');

$this->assertEquals('foobar', $translator->trans('bar'));
}

Expand Down