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/translation-caching-broken' of https://github.co…
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ protected function loadMessages($textDomain, $locale)
if (null !== ($cache = $this->getCache())) {
$cacheId = 'Zend_I18n_Translator_Messages_' . md5($textDomain . $locale);

if (false !== ($result = $cache->getItem($cacheId))) {
if (null !== ($result = $cache->getItem($cacheId))) {
$this->messages[$textDomain][$locale] = $result;
return;
}
Expand Down
14 changes: 14 additions & 0 deletions test/Translator/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ public function testTranslate()
$this->assertEquals('bar', $this->translator->translate('foo'));
}


public function testTranslateWithCache()
{
$cache = \Zend\Cache\StorageFactory::factory(array('adapter' => 'memory'));
$this->translator->setCache($cache);

$loader = new TestLoader();
$loader->textDomain = new TextDomain(array('foo' => 'bar'));
$this->translator->getPluginManager()->setService('test', $loader);
$this->translator->addTranslationFile('test', null);

$this->assertEquals('bar', $this->translator->translate('foo'));
}

public function testTranslatePlurals()
{
$this->translator->setLocale('en_EN');
Expand Down

0 comments on commit 30d1dd2

Please sign in to comment.