Skip to content

Commit

Permalink
Fix for empty messages failure
Browse files Browse the repository at this point in the history
  • Loading branch information
pix-art committed Dec 8, 2016
1 parent e097e89 commit 987eaf5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Twig/Extension/TranslationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function transchoice($message, $count, array $arguments = array(), $domai
return $this->getTranslator()->transChoice($message, $count, array_merge(array('%count%' => $count), $arguments), $domain, $locale);
}

protected function validateTranslation($id, $domain = null, $locale = null)
protected function validateTranslation($message, $domain = null, $locale = null)
{
if (null === $locale) {
$locale = $this->getTranslator()->getLocale();
Expand All @@ -62,14 +62,15 @@ protected function validateTranslation($id, $domain = null, $locale = null)

if ($this->autoDiscover &&
in_array($domain, $this->autoDomains) &&
!$this->translationExists($id, $domain, $locale)) {
!$this->translationExists($message, $domain, $locale) &&
!is_null($message)) {

$transUnit = $this->storage->getTransUnitByKeyAndDomain($id, $domain);
$transUnit = $this->storage->getTransUnitByKeyAndDomain($message, $domain);
if (!$transUnit) {
$transUnit = $this->transUnitManager->create($id, $domain);
$transUnit = $this->transUnitManager->create($message, $domain);
}

$this->transUnitManager->addTranslation($transUnit, $locale, $id, null, true);
$this->transUnitManager->addTranslation($transUnit, $locale, $message, null, true);
}
}

Expand Down

0 comments on commit 987eaf5

Please # to comment.