Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix loading of a text domain from different sources, fixes issue #4045 #4085

Closed
wants to merge 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2013
  1. @DASPRiD
This page is out of date. Refresh to see the latest.
View
9 library/Zend/I18n/Translator/Translator.php
@@ -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;
View
23 tests/ZendTest/I18n/Translator/TranslatorTest.php
@@ -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(
Something went wrong with that request. Please try again.