[BUGFIX] RTE: Localization to content language does not work
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 15 Oct 2012 18:21:45 +0000 (14:21 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 15 Oct 2012 20:21:21 +0000 (22:21 +0200)
Solution: Create content language service

Change-Id: I8a628a9c195c8634d8a13d193e9d161ee785960b
Resolves: #39271
Releases: 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/15650
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/Classes/BrowseLinks.php
typo3/sysext/rtehtmlarea/Classes/RteHtmlAreaBase.php

index a2265dd..ce82c99 100644 (file)
@@ -11,10 +11,16 @@ namespace TYPO3\CMS\Rtehtmlarea;
 class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
 
        public $editorNo;
-
+       /**
+        * TYPO3 language code of the content language
+        */
        public $contentTypo3Language;
 
        public $contentTypo3Charset = 'utf-8';
+       /**
+        * Language service object for localization to the content language
+        */
+       protected $contentLanguageService;
 
        public $additionalAttributes = array();
 
@@ -47,6 +53,9 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         */
        public function init() {
                $this->initVariables();
+               // Create content laguage service
+               $this->contentLanguageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
+               $this->contentLanguageService->init($this->contentTypo3Language);
                $this->initConfiguration();
                // init fileProcessor
                $this->fileProcessor = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
@@ -942,11 +951,7 @@ class BrowseLinks extends \TYPO3\CMS\Recordlist\Browser\ElementBrowser {
         * @return      string          Localized string.
         */
        public function getLLContent($string) {
-               $BE_lang = $GLOBALS['LANG']->lang;
-               $GLOBALS['LANG']->lang = $this->contentTypo3Language;
-               $LLString = $GLOBALS['LANG']->sL($string);
-               $GLOBALS['LANG']->lang = $BE_lang;
-               return $LLString;
+               return $this->contentLanguageService->sL($string);
        }
 
        /**
index 72ef71b..3e520b4 100644 (file)
@@ -201,11 +201,18 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
        public $confValues;
 
        public $language;
-
+       /**
+        * TYPO3 language code of the content language
+        */
        public $contentTypo3Language;
-
+       /**
+        * ISO language code of the content language
+        */
        public $contentISOLanguage;
-
+       /**
+        * Language service object for localization to the content language
+        */
+       protected $contentLanguageService;
        public $charset = 'utf-8';
 
        public $contentCharset = 'utf-8';
@@ -243,7 +250,7 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
 
        // Array of registered plugins indexed by their plugin Id's
        protected $fullScreen = FALSE;
-
+       // Page renderer object
        protected $pageRenderer;
 
        /**
@@ -422,6 +429,9 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                                        }
                                }
                        }
+                       // Create content laguage service
+                       $this->contentLanguageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
+                       $this->contentLanguageService->init($this->contentTypo3Language);
                        /* =======================================
                         * TOOLBAR CONFIGURATION
                         * =======================================
@@ -1242,11 +1252,7 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
         * @return      string          Localized string.
         */
        public function getLLContent($string) {
-               $BE_lang = $GLOBALS['LANG']->lang;
-               $GLOBALS['LANG']->lang = $this->contentTypo3Language;
-               $LLString = $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL($string));
-               $GLOBALS['LANG']->lang = $BE_lang;
-               return $LLString;
+               return $this->contentLanguageService->JScharCode($this->contentLanguageService->sL($string));
        }
 
        public function getPageConfigLabel($string, $JScharCode = 1) {