Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4085'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Willbanks committed Mar 20, 2013
2 parents d680762 + e8dede5 commit 84844ae
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,10 @@ protected function loadMessages($textDomain, $locale)
}
}

$messagesLoaded = (
$this->loadMessagesFromRemote($textDomain, $locale)
|| $this->loadMessagesFromPatterns($textDomain, $locale)
|| $this->loadMessagesFromFiles($textDomain, $locale)
);
$messagesLoaded = false;
$messagesLoaded |= $this->loadMessagesFromRemote($textDomain, $locale);
$messagesLoaded |= $this->loadMessagesFromPatterns($textDomain, $locale);
$messagesLoaded |= $this->loadMessagesFromFiles($textDomain, $locale);

if (!$messagesLoaded) {
$this->messages[$textDomain][$locale] = null;
Expand Down
23 changes: 23 additions & 0 deletions test/Translator/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ public function testTranslationFromSeveralTranslationFiles()
$this->assertEquals('Nachricht 11 - 1', $translator->translatePlural('Message 11', 'Message 11', 2)); //translation-more-de_DE.php
}

public function testTranslationFromDifferentSourceTypes()
{
$translator = Translator::factory(array(
'locale' => 'de_DE',
'translation_file_patterns' => array(
array(
'type' => 'phparray',
'base_dir' => $this->testFilesDir . '/testarray',
'pattern' => 'translation-de_DE.php'
),
),
'translation_files' => array(
array(
'type' => 'phparray',
'filename' => $this->testFilesDir . '/testarray/translation-more-de_DE.php'
)
)
));

$this->assertEquals('Nachricht 1', $translator->translate('Message 1')); //translation-de_DE.php
$this->assertEquals('Nachricht 9', $translator->translate('Message 9')); //translation-more-de_DE.php
}

public function testFactoryCreatesTranslatorWithCache()
{
$translator = Translator::factory(array(
Expand Down

0 comments on commit 84844ae

Please sign in to comment.