Prechádzať zdrojové kódy

wipfix: if header does not exist, always use fallback language

rugk 1 mesiac pred
rodič
commit
d3ecfc77a9
1 zmenil súbory, kde vykonal 5 pridanie a 0 odobranie
  1. 5 0
      lib/I18n.php

+ 5 - 0
lib/I18n.php

@@ -14,6 +14,7 @@ namespace PrivateBin;
 use AppendIterator;
 use AppendIterator;
 use GlobIterator;
 use GlobIterator;
 use function in_array;
 use function in_array;
+use function array_key_exists;
 
 
 /**
 /**
  * I18n
  * I18n
@@ -199,6 +200,10 @@ class I18n
      */
      */
     private static function _getLanguageFromHttpHeader($availableLanguages)
     private static function _getLanguageFromHttpHeader($availableLanguages)
     {
     {
+        if (!array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
+            return self::$_languageFallback;
+        }
+
         // as per https://stackoverflow.com/a/9051957/5008962 we can use the I10n module
         // as per https://stackoverflow.com/a/9051957/5008962 we can use the I10n module
         // if loaded, but it only returns the primary preference (aka one string)
         // if loaded, but it only returns the primary preference (aka one string)
         if (function_exists('locale_accept_from_http')) {
         if (function_exists('locale_accept_from_http')) {