@@ -135,7 +135,6 @@ public function getForm(): TemplateResponse {
135135 $ totalSpace = \OC_Helper::humanFileSize ($ storageInfo ['total ' ]);
136136 }
137137
138- $ localeParameters = $ this ->getLocales ($ user );
139138 $ messageParameters = $ this ->getMessageParameters ($ account );
140139
141140 $ parameters = [
@@ -157,14 +156,15 @@ public function getForm(): TemplateResponse {
157156 'groups ' => $ this ->getGroups ($ user ),
158157 'isFairUseOfFreePushService ' => $ this ->isFairUseOfFreePushService (),
159158 'profileEnabledGlobally ' => $ this ->profileManager ->isProfileEnabled (),
160- ] + $ messageParameters + $ localeParameters ;
159+ ] + $ messageParameters ;
161160
162161 $ personalInfoParameters = [
163162 'userId ' => $ uid ,
164163 'displayName ' => $ this ->getProperty ($ account , IAccountManager::PROPERTY_DISPLAYNAME ),
165164 'twitter ' => $ this ->getProperty ($ account , IAccountManager::PROPERTY_TWITTER ),
166165 'emailMap ' => $ this ->getEmailMap ($ account ),
167166 'languageMap ' => $ this ->getLanguageMap ($ user ),
167+ 'localeMap ' => $ this ->getLocaleMap ($ user ),
168168 'profileEnabledGlobally ' => $ this ->profileManager ->isProfileEnabled (),
169169 'profileEnabled ' => $ this ->profileManager ->isProfileEnabled ($ user ),
170170 'organisation ' => $ this ->getProperty ($ account , IAccountManager::PROPERTY_ORGANISATION ),
@@ -319,31 +319,24 @@ private function getLanguageMap(IUser $user): array {
319319 );
320320 }
321321
322- private function getLocales (IUser $ user ): array {
322+ private function getLocaleMap (IUser $ user ): array {
323323 $ forceLanguage = $ this ->config ->getSystemValue ('force_locale ' , false );
324324 if ($ forceLanguage !== false ) {
325325 return [];
326326 }
327327
328328 $ uid = $ user ->getUID ();
329-
330329 $ userLocaleString = $ this ->config ->getUserValue ($ uid , 'core ' , 'locale ' , $ this ->l10nFactory ->findLocale ());
331-
332330 $ userLang = $ this ->config ->getUserValue ($ uid , 'core ' , 'lang ' , $ this ->l10nFactory ->findLanguage ());
333-
334331 $ localeCodes = $ this ->l10nFactory ->findAvailableLocales ();
335-
336- $ userLocale = array_filter ($ localeCodes , function ($ value ) use ($ userLocaleString ) {
337- return $ userLocaleString === $ value ['code ' ];
338- });
332+ $ userLocale = array_filter ($ localeCodes , fn ($ value ) => $ userLocaleString === $ value ['code ' ]);
339333
340334 if (!empty ($ userLocale )) {
341335 $ userLocale = reset ($ userLocale );
342336 }
343337
344- $ localesForLanguage = array_filter ($ localeCodes , function ($ localeCode ) use ($ userLang ) {
345- return 0 === strpos ($ localeCode ['code ' ], $ userLang );
346- });
338+ $ localesForLanguage = array_values (array_filter ($ localeCodes , fn ($ localeCode ) => strpos ($ localeCode ['code ' ], $ userLang ) === 0 ));
339+ $ otherLocales = array_values (array_filter ($ localeCodes , fn ($ localeCode ) => strpos ($ localeCode ['code ' ], $ userLang ) !== 0 ));
347340
348341 if (!$ userLocale ) {
349342 $ userLocale = [
@@ -353,10 +346,10 @@ private function getLocales(IUser $user): array {
353346 }
354347
355348 return [
356- 'activelocaleLang ' => $ userLocaleString ,
357- 'activelocale ' => $ userLocale ,
358- 'locales ' => $ localeCodes ,
349+ 'activeLocaleLang ' => $ userLocaleString ,
350+ 'activeLocale ' => $ userLocale ,
359351 'localesForLanguage ' => $ localesForLanguage ,
352+ 'otherLocales ' => $ otherLocales ,
360353 ];
361354 }
362355
0 commit comments