Skip to content

Commit bfee0ea

Browse files
committed
fix: actually fallback to the original value if the translated value is null.
This makes sense i think because if its not set then we do want to fallback. If it is set it would use the set value.
1 parent 8bad537 commit bfee0ea

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Traits/IsTranslatable.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,12 @@ public function getAttribute($key): mixed
210210
}, $key);
211211
}
212212

213-
// translate using current app locale if possible
213+
// Translate using the current app locale if possible
214214
if ($this->isTranslatable($key)) {
215-
return $this->translate($key, app()->currentLocale());
215+
$translated_value = $this->translate($key, app()->currentLocale());
216+
217+
// Return translated value if not null, otherwise fallback to original value
218+
return $translated_value ?? parent::getAttribute($key);
216219
}
217220

218221
// check if is a suffixed attribute

0 commit comments

Comments
 (0)