Skip to content

Commit 37d3503

Browse files
authored
Merge pull request #1709 from Uplink03/falsy-translations
fix translation when the value is falsy (e.g empty string, '0', null)
2 parents a872c4d + 6cc9fb3 commit 37d3503

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/Gedmo/Translatable/TranslatableListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,14 +471,16 @@ public function postLoad(EventArgs $args)
471471
// translate object's translatable properties
472472
foreach ($config['fields'] as $field) {
473473
$translated = '';
474+
$is_translated = false;
474475
foreach ((array) $result as $entry) {
475476
if ($entry['field'] == $field) {
476477
$translated = $entry['content'];
478+
$is_translated = true;
477479
break;
478480
}
479481
}
480482
// update translation
481-
if ($translated
483+
if ($is_translated
482484
|| (!$this->translationFallback && (!isset($config['fallback'][$field]) || !$config['fallback'][$field]))
483485
|| ($this->translationFallback && isset($config['fallback'][$field]) && !$config['fallback'][$field])
484486
) {

0 commit comments

Comments
 (0)