[UTIL][Common] Respect detect language setting
Minor bug fix
This commit is contained in:
parent
d857baa0f1
commit
893d299e29
|
@ -547,7 +547,7 @@ class Actor extends Entity
|
|||
if (\defined($const)) {
|
||||
return $this->type === \constant($const);
|
||||
} else {
|
||||
throw new BugFoundException("Actor cannot be a '{$type}', check your spelling");
|
||||
throw new BugFoundException("Actor cannot be a '{$type}', check your spelling.");
|
||||
}
|
||||
} else {
|
||||
return parent::__call($name, $arguments);
|
||||
|
|
|
@ -328,6 +328,18 @@ abstract class Common
|
|||
|
||||
public static function currentLanguage(): 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'));
|
||||
// Prefer the Actor's language, if set.
|
||||
$language = self::actor()?->getTopLanguage();
|
||||
if (!\is_null($language)) {
|
||||
return $language;
|
||||
}
|
||||
if (
|
||||
self::config('site', 'detect_language')
|
||||
&& !\is_null(self::$request?->headers)
|
||||
&& self::$request->headers->has('accept-language')
|
||||
) {
|
||||
return Language::getByLocale(I18n::clientPreferredLanguage(self::$request->headers->get('accept-language')));
|
||||
}
|
||||
return Language::getByLocale(self::config('site', 'language'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user