]> git.agnieray.net Git - galette.git/commitdiff
Fix locales load from HTTP header 0.9.6
authorJohan Cwiklinski <johan@x-tnd.be>
Mon, 29 Nov 2021 11:27:56 +0000 (12:27 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Mon, 29 Nov 2021 11:27:56 +0000 (12:27 +0100)
galette/lib/Galette/Core/I18n.php

index e37313fe8bbd09189f7be1579aa7c274719562ce..bf82e8d16ba2216a4b5043c177a4e4dca8b96222 100644 (file)
@@ -100,9 +100,13 @@ class I18n
                 arsort($preferred_locales);
 
                 foreach (array_keys($preferred_locales) as $preferred_locale) {
-                    if (array_key_exists(str_replace('-', '_', $preferred_locale), $this->langs)) {
-                        $dlang = str_replace('-', '_', $preferred_locale);
-                        break;
+                    $short_locale = explode('_', $preferred_locale)[0];
+                    foreach (array_keys($this->langs) as $lang) {
+                        $short_key = explode('_', $lang)[0];
+                        if ($short_key == $short_locale) {
+                            $dlang = $lang;
+                            break;
+                        }
                     }
                 }
             }