Skip to content

Commit

Permalink
Merge pull request #1709 from Uplink03/falsy-translations
Browse files Browse the repository at this point in the history
fix translation when the value is falsy (e.g empty string, '0', null)
  • Loading branch information
l3pp4rd authored Nov 28, 2016
2 parents a872c4d + 6cc9fb3 commit 37d3503
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Gedmo/Translatable/TranslatableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,14 +471,16 @@ public function postLoad(EventArgs $args)
// translate object's translatable properties
foreach ($config['fields'] as $field) {
$translated = '';
$is_translated = false;
foreach ((array) $result as $entry) {
if ($entry['field'] == $field) {
$translated = $entry['content'];
$is_translated = true;
break;
}
}
// update translation
if ($translated
if ($is_translated
|| (!$this->translationFallback && (!isset($config['fallback'][$field]) || !$config['fallback'][$field]))
|| ($this->translationFallback && isset($config['fallback'][$field]) && !$config['fallback'][$field])
) {
Expand Down

0 comments on commit 37d3503

Please sign in to comment.