[COMPONENT][Collection] Use current locale

This commit is contained in:
Hugo Sales 2022-01-08 15:12:31 +00:00
parent c835fc6aca
commit da6d3bd351
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0
2 changed files with 2 additions and 2 deletions

View File

@ -14,7 +14,7 @@ class Collection extends Controller
public function query(string $query, ?string $locale = null, ?Actor $actor = null)
{
$actor ??= Common::actor();
$locale ??= $actor?->getTopLanguage()?->getLocale();
$locale ??= $actor?->getTopLanguage()?->getLocale() ?? Common::currentLanguage()->getLocale();
return CollectionModule::query($query, $this->int('page') ?? 1, $locale, $actor);
}
}

View File

@ -323,6 +323,6 @@ abstract class Common
public static function currentLanguage(): Language
{
return self::actor()?->getTopLanguage() ?? Language::getByLocale(!\is_null(self::$request->headers->get('accept-language')) ? I18n::clientPreferredLanguage(self::$request->headers->get('accept-language')) : self::config('site', 'language'));
return self::actor()?->getTopLanguage() ?? Language::getByLocale(self::$request->headers->has('accept-language') ? I18n::clientPreferredLanguage(self::$request->headers->get('accept-language')) : self::config('site', 'language'));
}
}