[BUGFIX] Use English labels if browser's preferred language is English 80/52280/2
authorXavier Perseguers <xavier@typo3.org>
Fri, 31 Mar 2017 07:38:54 +0000 (09:38 +0200)
committerXavier Perseguers <xavier@typo3.org>
Mon, 3 Apr 2017 08:58:55 +0000 (10:58 +0200)
Change-Id: Ic9cb3f3e3e0547e4a0d34bf50f481e2f3844f610
Resolves: #80593
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/52280
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Thomas Hohn <thomas@hohn.dk>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Daniel Goerz <ervaude@gmail.com>
Tested-by: Daniel Goerz <ervaude@gmail.com>
Reviewed-by: Xavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers <xavier@typo3.org>
typo3/sysext/core/Classes/Localization/Locales.php
typo3/sysext/core/Tests/Unit/Localization/LocalesTest.php

index 04e5822..bdbab8e 100644 (file)
@@ -218,7 +218,7 @@ class Locales implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function getPreferredClientLanguage($languageCodesList)
     {
-        $allLanguageCodesFromLocales = [];
+        $allLanguageCodesFromLocales = ['en' => 'default'];
         foreach ($this->getIsoMapping() as $typo3Lang => $isoLang) {
             $isoLang = str_replace('_', '-', $isoLang);
             $allLanguageCodesFromLocales[$isoLang] = $typo3Lang;
index 1699b3a..8048227 100644 (file)
@@ -42,4 +42,14 @@ class LocalesTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
         $detectedLanguage = $this->subject->getPreferredClientLanguage($browserPreferredLanguageHeader);
         $this->assertSame('de', $detectedLanguage);
     }
+
+    /**
+     * @test
+     */
+    public function englishMayBeDefaultLanguage()
+    {
+        $browserPreferredLanguageHeader = 'en-US;q=0.8,en;q=0.6;de-DE,de;q=0.4';
+        $detectedLanguage = $this->subject->getPreferredClientLanguage($browserPreferredLanguageHeader);
+        $this->assertSame('default', $detectedLanguage);
+    }
 }