Skip to content

Commit

Permalink
Merge pull request #12 from latevaweb/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
latevaweb authored Apr 23, 2020
2 parents 579b5b8 + d0cc774 commit e2a706e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Traits/Translatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public function getTranslatableAttributes(): array

public function getTranslation(string $field, string $locale, bool $useFallbackLocale = true): ?string
{
$locale = $this->normalizeLocale($field, $locale, $useFallbackLocale);

$translations = $this->getTranslations($field)->all();

$locale = $this->normalizeLocale(array_keys($translations), $field, $locale, $useFallbackLocale);

$translation = $translations[$locale] ?? '';

if ($this->hasGetMutator($field)) {
Expand Down Expand Up @@ -128,9 +128,9 @@ public function translations(): MorphToMany
'translation_id');
}

protected function normalizeLocale(string $field, string $locale, bool $useFallbackLocale): string
protected function normalizeLocale($locales, string $field, string $locale, bool $useFallbackLocale): string
{
if (in_array($locale, $this->getTranslatedLocales($field)->all())) {
if (in_array($locale, $locales)) {
return $locale;
}
if (! $useFallbackLocale) {
Expand Down

0 comments on commit e2a706e

Please sign in to comment.