diff options
author | Christopher Ng <chrng8@gmail.com> | 2022-08-11 05:54:08 +0000 |
---|---|---|
committer | Christopher Ng <chrng8@gmail.com> | 2022-09-16 19:02:18 +0000 |
commit | f922b2fd7072ace8211467e3627f2a44a5c09fe3 (patch) | |
tree | d218fb323c4445659576a70a5cfc8ea7af149a79 /apps/settings/lib | |
parent | b9c002df0a3ab80c1612206cfb1f724d90e0da3a (diff) | |
download | nextcloud-server-f922b2fd7072ace8211467e3627f2a44a5c09fe3.tar.gz nextcloud-server-f922b2fd7072ace8211467e3627f2a44a5c09fe3.zip |
Remake locale saving with Vue
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Diffstat (limited to 'apps/settings/lib')
-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, ]; } |