Skip to content

Commit

Permalink
Add useFallbacklocale
Browse files Browse the repository at this point in the history
  • Loading branch information
petrzpav committed Nov 20, 2024
1 parent f052b5e commit d07ad32
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Traits/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public function getAttribute($key)
/**
* Return translations accroding to config.languages
*/
public function getAttributeTranslations($key)
public function getAttributeTranslations($key, $useFallbackLocale = true)
{
foreach (config('languages') as $locale => $language) {
$translations[$locale] = $this->translate($key, $locale, app()->getFallbackLocale());
$fallbackLocale = $useFallbackLocale ? app()->getFallbackLocale() : $locale;
$translations[$locale] = $this->translate($key, $locale, $fallbackLocale);
}

return $translations;
Expand Down

0 comments on commit d07ad32

Please sign in to comment.