Skip to content

Commit a6f0278

Browse files
committed
Default to language from request in L10N\Factory->getUserLanguage()
Try to get the language from request before falling back to the instance default. This fixes the detected user language during first login of a new user and ensures that the returned language is consistent during the login. Also partially fixes a bug with Collectives folder being initialized in different languages at first login, see https://gitlab.com/collectivecloud/collectives/-/issues/238 Signed-off-by: Jonas Meurer <jonas@freesources.org>
1 parent 6572f80 commit a6f0278

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/private/L10N/Factory.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ public function getUserLanguage(IUser $user = null): string {
431431
if ($language !== null) {
432432
return $language;
433433
}
434+
435+
// Use language from request
436+
if ($this->userSession->getUser() instanceof IUser &&
437+
$user->getUID() === $this->userSession->getUser()->getUID()) {
438+
try {
439+
return $this->getLanguageFromRequest();
440+
} catch (LanguageNotFoundException $e) {
441+
}
442+
}
434443
}
435444

436445
return $this->config->getSystemValue('default_language', 'en');

0 commit comments

Comments
 (0)