]> git.mxchange.org Git - friendica.git/commitdiff
Simplified conversion
authorMichael <heluecht@pirati.ca>
Sun, 3 Sep 2023 19:22:52 +0000 (19:22 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 3 Sep 2023 19:22:52 +0000 (19:22 +0000)
src/Core/L10n.php

index 9d1fa70167a7a60fe352281b7f6bb26525f0615a..96935a4ed6c3a8828d2fdbb4a0b55d18236b44be 100644 (file)
@@ -414,16 +414,15 @@ class L10n
         */
        public function convertForLanguageDetection(array $languages): array
        {
-               $languages['fi'] = $languages['fi-fi'];
-               unset($languages['fi-fi']);
-               $languages['da'] = $languages['da-dk'];
-               unset($languages['da-dk']);
-               $languages['nb'] = $languages['nb-no'];
-               unset($languages['nb-no']);
-               $languages['pt-BR'] = $languages['pt-br'];
-               unset($languages['pt-br']);
-               $languages['zh-Hans'] = $languages['zh-cn'];
-               unset($languages['zh-cn']);
+               foreach ($languages as $key => $language) {
+                       $newkey = $this->convertCodeForLanguageDetection($key);
+                       if ($newkey != $key) {
+                               if (!isset($languages[$newkey])) {
+                                       $languages[$newkey] = $language;
+                               }
+                               unset($languages[$key]);
+                       }
+               }
 
                ksort($languages);