diff options
Diffstat (limited to 'apps/settings/lib/Settings/Personal/PersonalInfo.php')
-rw-r--r-- | apps/settings/lib/Settings/Personal/PersonalInfo.php | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index c5e40914ecf..56291cd3d35 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -135,7 +135,6 @@ class PersonalInfo implements ISettings { $totalSpace = \OC_Helper::humanFileSize($storageInfo['total']); } - $localeParameters = $this->getLocales($user); $messageParameters = $this->getMessageParameters($account); $parameters = [ @@ -143,7 +142,7 @@ class PersonalInfo implements ISettings { 'lookupServerUploadEnabled' => $lookupServerUploadEnabled, 'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(), 'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(), - ] + $messageParameters + $localeParameters; + ] + $messageParameters; $personalInfoParameters = [ 'userId' => $uid, @@ -160,6 +159,7 @@ class PersonalInfo implements ISettings { 'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE), 'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER), 'languageMap' => $this->getLanguageMap($user), + 'localeMap' => $this->getLocaleMap($user), 'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(), 'profileEnabled' => $this->profileManager->isProfileEnabled($user), 'organisation' => $this->getProperty($account, IAccountManager::PROPERTY_ORGANISATION), @@ -315,31 +315,24 @@ class PersonalInfo implements ISettings { ); } - private function getLocales(IUser $user): array { + private function getLocaleMap(IUser $user): array { $forceLanguage = $this->config->getSystemValue('force_locale', false); if ($forceLanguage !== false) { return []; } $uid = $user->getUID(); - $userLocaleString = $this->config->getUserValue($uid, 'core', 'locale', $this->l10nFactory->findLocale()); - $userLang = $this->config->getUserValue($uid, 'core', 'lang', $this->l10nFactory->findLanguage()); - $localeCodes = $this->l10nFactory->findAvailableLocales(); - - $userLocale = array_filter($localeCodes, function ($value) use ($userLocaleString) { - return $userLocaleString === $value['code']; - }); + $userLocale = array_filter($localeCodes, fn ($value) => $userLocaleString === $value['code']); if (!empty($userLocale)) { $userLocale = reset($userLocale); } - $localesForLanguage = array_filter($localeCodes, function ($localeCode) use ($userLang) { - return 0 === strpos($localeCode['code'], $userLang); - }); + $localesForLanguage = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) === 0)); + $otherLocales = array_values(array_filter($localeCodes, fn ($localeCode) => strpos($localeCode['code'], $userLang) !== 0)); if (!$userLocale) { $userLocale = [ @@ -349,10 +342,10 @@ class PersonalInfo implements ISettings { } return [ - 'activelocaleLang' => $userLocaleString, - 'activelocale' => $userLocale, - 'locales' => $localeCodes, + 'activeLocaleLang' => $userLocaleString, + 'activeLocale' => $userLocale, 'localesForLanguage' => $localesForLanguage, + 'otherLocales' => $otherLocales, ]; } |