[!!!][TASK] Remove config.language_alt and config.language 42/60842/5
authorBenni Mack <benni@typo3.org>
Wed, 29 May 2019 21:07:19 +0000 (23:07 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 3 Jun 2019 11:10:16 +0000 (13:10 +0200)
Due to site handling, the TypoScript properties config.language
and config.language_alt have no effect anymore and can be removed.

This patch removes the last forgotten occurrences.

Resolves: #88459
Releases: master
Change-Id: Ic4793035264cc00fe1e5d22b6b1c7cafdbdc49ed
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60842
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Documentation/Changelog/master/Breaking-87193-DeprecatedFunctionalityRemoved.rst
typo3/sysext/extbase/Classes/Utility/LocalizationUtility.php
typo3/sysext/felogin/Tests/Unit/Controller/FrontendLoginControllerTest.php
typo3/sysext/form/Classes/Service/TranslationService.php
typo3/sysext/frontend/Classes/Plugin/AbstractPlugin.php
typo3/sysext/frontend/Tests/Unit/Plugin/AbstractPluginTest.php
typo3/sysext/t3editor/Resources/Private/tsref.xml
typo3/sysext/t3editor/Resources/Public/JavaScript/Mode/typoscript/typoscript.js

index 8b45ffa..4b3ae8b 100644 (file)
@@ -1246,6 +1246,7 @@ The following TypoScript options have been dropped:
 * `config.concatenateJsAndCss`
 * `config.defaultGetVars`
 * `config.language`
+* `config.language_alt`
 * `config.locale_all`
 * `config.sys_language_isocode`
 * `config.sys_language_isocode_default`
index 13d5b9e..338e47d 100644 (file)
@@ -63,7 +63,7 @@ class LocalizationUtility
      * @param string|null $extensionName The name of the extension
      * @param array $arguments The arguments of the extension, being passed over to vsprintf
      * @param string $languageKey The language key or null for using the current language from the system
-     * @param string[] $alternativeLanguageKeys The alternative language keys if no translation was found. If null and we are in the frontend, then the language_alt from TypoScript setup will be used
+     * @param string[] $alternativeLanguageKeys The alternative language keys if no translation was found.
      * @return string|null The value from LOCAL_LANG or null if no translation was found.
      */
     public static function translate(string $key, ?string $extensionName = null, array $arguments = null, string $languageKey = null, array $alternativeLanguageKeys = null): ?string
@@ -180,8 +180,7 @@ class LocalizationUtility
     }
 
     /**
-     * Sets the currently active language/language_alt keys.
-     * Default values are "default" for language key and an empty array for language_alt key.
+     * Sets the currently active language keys.
      *
      * @return array
      */
@@ -192,25 +191,15 @@ class LocalizationUtility
             'alternativeLanguageKeys' => [],
         ];
         if (TYPO3_MODE === 'FE') {
-            $tsfe = static::getTypoScriptFrontendController();
             $siteLanguage = self::getCurrentSiteLanguage();
 
-            // Get values from site language, which takes precedence over TypoScript settings
-            if ($siteLanguage instanceof SiteLanguage) {
-                $languageKeys['languageKey'] = $siteLanguage->getTypo3Language();
-            } elseif (isset($tsfe->config['config']['language'])) {
-                $languageKeys['languageKey'] = $tsfe->config['config']['language'];
-                if (isset($tsfe->config['config']['language_alt'])) {
-                    $languageKeys['alternativeLanguageKeys'] = $tsfe->config['config']['language_alt'];
-                }
-            }
+            // Get values from site language
+            $languageKeys['languageKey'] = $siteLanguage->getTypo3Language();
 
-            if (empty($languageKeys['alternativeLanguageKeys'])) {
-                $locales = GeneralUtility::makeInstance(Locales::class);
-                if (in_array($languageKeys['languageKey'], $locales->getLocales())) {
-                    foreach ($locales->getLocaleDependencies($languageKeys['languageKey']) as $language) {
-                        $languageKeys['alternativeLanguageKeys'] = $language;
-                    }
+            $locales = GeneralUtility::makeInstance(Locales::class);
+            if (in_array($languageKeys['languageKey'], $locales->getLocales())) {
+                foreach ($locales->getLocaleDependencies($languageKeys['languageKey']) as $language) {
+                    $languageKeys['alternativeLanguageKeys'] = $language;
                 }
             }
         } elseif (!empty($GLOBALS['BE_USER']->uc['lang'])) {
@@ -322,14 +311,6 @@ class LocalizationUtility
         return null;
     }
 
-    /**
-     * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
-     */
-    protected static function getTypoScriptFrontendController(): \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
-    {
-        return $GLOBALS['TSFE'];
-    }
-
     /**
      * @return \TYPO3\CMS\Core\Localization\LanguageService
      */
index d810aba..9bc8cfd 100644 (file)
@@ -16,6 +16,9 @@ namespace TYPO3\CMS\Felogin\Tests\Unit\Controller;
  */
 
 use TYPO3\CMS\Core\Authentication\LoginType;
+use TYPO3\CMS\Core\Http\ServerRequest;
+use TYPO3\CMS\Core\Http\Uri;
+use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Felogin\Controller\FrontendLoginController;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
@@ -30,6 +33,7 @@ class FrontendLoginControllerTest extends UnitTestCase
 
     public function setUp(): void
     {
+        $GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())->withAttribute('language', new SiteLanguage(0, 'en_US', new Uri('/'), ['typo3Language' => 'en']));
         $GLOBALS['TSFE'] = new \stdClass();
         parent::setUp();
     }
index 5e7d91f..50016fc 100644 (file)
@@ -29,7 +29,6 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
 use TYPO3\CMS\Form\Domain\Model\FormElements\FormElementInterface;
 use TYPO3\CMS\Form\Domain\Model\Renderable\RootRenderableInterface;
 use TYPO3\CMS\Form\Domain\Runtime\FormRuntime;
-use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
 
 /**
  * Advanced translations
@@ -550,8 +549,7 @@ class TranslationService implements SingletonInterface
     }
 
     /**
-     * Sets the currently active language/language_alt keys.
-     * Default values are "default" for language key and "" for language_alt key.
+     * Sets the currently active language keys.
      */
     protected function setLanguageKeys()
     {
@@ -559,18 +557,9 @@ class TranslationService implements SingletonInterface
 
         $this->alternativeLanguageKeys = [];
         if (TYPO3_MODE === 'FE') {
-            $tsfe = $this->getTypoScriptFrontendController();
-
-            if ($this->getCurrentSiteLanguage() instanceof SiteLanguage) {
-                $this->languageKey = $this->getCurrentSiteLanguage()->getTypo3Language();
-            } elseif (isset($tsfe->config['config']['language'])) {
-                $this->languageKey = $tsfe->config['config']['language'];
-                if (isset($tsfe->config['config']['language_alt'])) {
-                    $this->alternativeLanguageKeys[] = $tsfe->config['config']['language_alt'];
-                }
-            }
+            $this->languageKey = $this->getCurrentSiteLanguage()->getTypo3Language();
 
-            if ($this->languageKey !== 'default' && empty($this->alternativeLanguageKeys)) {
+            if ($this->languageKey !== 'default') {
                 /** @var \TYPO3\CMS\Core\Localization\Locales $locales */
                 $locales = GeneralUtility::makeInstance(Locales::class);
                 if (in_array($this->languageKey, $locales->getLocales(), true)) {
@@ -701,12 +690,4 @@ class TranslationService implements SingletonInterface
     {
         return $GLOBALS['LANG'];
     }
-
-    /**
-     * @return TypoScriptFrontendController
-     */
-    protected function getTypoScriptFrontendController(): TypoScriptFrontendController
-    {
-        return $GLOBALS['TSFE'];
-    }
 }
index 03abf8d..5b7bae1 100644 (file)
@@ -263,25 +263,15 @@ class AbstractPlugin
                 $this->frontendController->reqCHash();
             }
         }
-        $siteLanguage = $this->getCurrentSiteLanguage();
-        if ($siteLanguage) {
-            $this->LLkey = $siteLanguage->getTypo3Language();
-        } elseif (!empty($this->frontendController->config['config']['language'])) {
-            $this->LLkey = $this->frontendController->config['config']['language'];
-        }
+        $this->LLkey = $this->getCurrentSiteLanguage()->getTypo3Language();
 
-        if (empty($this->frontendController->config['config']['language_alt'])) {
-            /** @var Locales $locales */
-            $locales = GeneralUtility::makeInstance(Locales::class);
-            if (in_array($this->LLkey, $locales->getLocales())) {
-                $this->altLLkey = '';
-                foreach ($locales->getLocaleDependencies($this->LLkey) as $language) {
-                    $this->altLLkey .= $language . ',';
-                }
-                $this->altLLkey = rtrim($this->altLLkey, ',');
+        /** @var Locales $locales */
+        $locales = GeneralUtility::makeInstance(Locales::class);
+        if (in_array($this->LLkey, $locales->getLocales())) {
+            foreach ($locales->getLocaleDependencies($this->LLkey) as $language) {
+                $this->altLLkey .= $language . ',';
             }
-        } else {
-            $this->altLLkey = $this->frontendController->config['config']['language_alt'];
+            $this->altLLkey = rtrim($this->altLLkey, ',');
         }
     }
 
index 204594f..a991b90 100644 (file)
@@ -14,6 +14,10 @@ namespace TYPO3\CMS\Frontend\Tests\Unit\Plugin;
  *
  * The TYPO3 project - inspiring people to share!
  */
+
+use TYPO3\CMS\Core\Http\ServerRequest;
+use TYPO3\CMS\Core\Http\Uri;
+use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
 use TYPO3\CMS\Frontend\ContentObject\TextContentObject;
@@ -51,6 +55,7 @@ class AbstractPluginTest extends UnitTestCase
         // Allow objects until 100 levels deep when executing the stdWrap
         $GLOBALS['TSFE'] = new \stdClass();
         $GLOBALS['TSFE']->cObjectDepthCounter = 100;
+        $GLOBALS['TYPO3_REQUEST'] = (new ServerRequest())->withAttribute('language', new SiteLanguage(0, 'en_US', new Uri('/'), ['typo3Language' => 'en']));
 
         $this->abstractPlugin = new AbstractPlugin();
         $contentObjectRenderer = new ContentObjectRenderer();
index d603a68..3c96071 100644 (file)
@@ -454,10 +454,6 @@ config.inlineStyle2TempFile = 1]]></description>
                        <default><![CDATA[
 ]]></default>
                </property>
-               <property name="language_alt" type="string">
-                       <description><![CDATA[If "config.language" (above) is used, this can be set to another language key which will be used for labels if a label was not found for the main language. For instance a brazil portuguese website might specify "pt" as alternative language which means the portuguese label will be shown if none was available in the main language, brazil portuguese. This feature makes sense if one language is incompletely translated and close to another language.]]></description>
-                       <default><![CDATA[
-]]></default>
                </property>
                <property name="linkVars" type="string">
                        <description><![CDATA[HTTP_GET_VARS, which should be passed on with links in TYPO3. This is compiled into a string stored in $GLOBALS["TSFE"]->linkVars
index f19ebd6..9f0dab2 100644 (file)
         'labelStdWrap': kw('labelStdWrap'),
         'labelWrap': kw('labelWrap'),
         'lang': kw('lang'),
-        'language': B,
-        'language_alt': kw('language_alt'),
         'languageField': kw('languageField'),
         'layout': A,
         'left': kw('left'),