Skip to content

Commit

Permalink
Merge pull request #43 from Kunstmaan/translator-bugfix
Browse files Browse the repository at this point in the history
Bugfix for Translator
  • Loading branch information
Wim Vandersmissen committed Jul 4, 2014
2 parents 6a64041 + 992c0c1 commit 35c1e58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Service/Translator/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function addResourcesFromCacher()

/**
* Add resources from the stash and cache them
*
* @param boolean $cacheResources cache resources after retrieving them from the stasher
*/
public function addResourcesFromDatabaseAndCacheThem($cacheResources = true)
Expand All @@ -67,13 +68,14 @@ public function addResourcesFromDatabaseAndCacheThem($cacheResources = true)
* Add resources to the Translator
* Resources is an array[0] => array('name' => 'messages', 'locale' => 'en')
* Where name is the domain of the domain
*
* @param array $resources
*/
public function addResources($resources)
{
foreach ($resources as $resource) {
$this->addResource('database', 'DB', $resource['locale'], $resource['name']);
}
}
}

/**
Expand All @@ -91,13 +93,15 @@ protected function loadCatalogue($locale)

public function trans($id, array $parameters = array(), $domain = 'messages', $locale = null)
{
if (!$this->container->isScopeActive('request')) {
return parent::trans($id, $parameters, $domain, $locale);
}

$showTranslationsSource = $this->container->get('request')->get('transSource');
if($showTranslationsSource !== null) {
$trans = sprintf('%s (%s)', $id, $domain);
if ($showTranslationsSource !== null) {
$trans = sprintf('%s (%s)', $id, $domain);
} else {
$trans = parent::trans($id, $parameters, $domain, $locale);

}

$this->profileTranslation($id, $parameters, $domain, $locale, $trans);
Expand Down Expand Up @@ -128,7 +132,7 @@ public function profileTranslation($id, $parameters, $domain, $locale, $trans)
$translationCollection = new ArrayCollection;
}

$translationCollection->set($domain.$id.$locale, $translation);
$translationCollection->set($domain . $id . $locale, $translation);

$this->container->get('request')->request->set('usedTranslations', $translationCollection);

Expand Down

0 comments on commit 35c1e58

Please sign in to comment.