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

Change-Id: I7353fe33bba13e38d4b7eb20e966895aa71bc3eb
Resolves: #39271
Releases: 4.6, 4.7, 6.0
Reviewed-on: http://review.typo3.org/15660
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php

index fd68ed8..7c862cd 100644 (file)
@@ -128,8 +128,18 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
        var $thisConfig;
        var $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 $contentCharset;
        public $OutputCharset;
        var $editorCSS;
@@ -322,7 +332,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                        }
                                }
                        }
-
+                       // Create content laguage service
+                       $this->contentLanguageService = t3lib_div::makeInstance('language');
+                       $this->contentLanguageService->init($this->contentTypo3Language);
                                // Character sets: interface and content
                        $this->charset = $LANG->charSet;
                        $this->OutputCharset = $this->charset;
@@ -1343,17 +1355,14 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                return json_encode($toolbar);
        }
 
+       /**
+        * Localize a string using the language of the content element rather than the language of the BE interface
+        *
+        * @param       string          string: the label to be localized
+        * @return      string          Localized string.
+        */
        public function getLLContent($string) {
-               global $LANG;
-
-               $BE_lang = $LANG->lang;
-               $BE_charSet = $LANG->charSet;
-               $LANG->lang = $this->contentTypo3Language;
-               $LANG->charSet = $this->contentCharset;
-               $LLString = $LANG->JScharCode($LANG->sL($string));
-               $LANG->lang = $BE_lang;
-               $LANG->charSet = $BE_charSet;
-               return $LLString;
+               return $this->contentLanguageService->JScharCode($this->contentLanguageService->sL($string));
        }
 
        public function getPageConfigLabel($string,$JScharCode=1) {
index b592ce9..004d017 100644 (file)
@@ -199,8 +199,15 @@ class tx_rtehtmlarea_folderTree extends rteFolderTree {
 class tx_rtehtmlarea_browse_links extends browse_links {
 
        var $editorNo;
-       var $contentTypo3Language;
-       var $contentTypo3Charset;
+       /**
+        * TYPO3 language code of the content language
+        */
+       public $contentTypo3Language;
+       var $contentTypo3Charset = 'utf-8';
+       /**
+        * Language service object for localization to the content language
+        */
+       protected $contentLanguageService;
        public $additionalAttributes = array();
        public $buttonConfig = array();
        public $RTEProperties = array();
@@ -224,6 +231,9 @@ class tx_rtehtmlarea_browse_links extends browse_links {
        function init() {
 
                $this->initVariables();
+               // Create content laguage service
+               $this->contentLanguageService = t3lib_div::makeInstance('language');
+               $this->contentLanguageService->init($this->contentTypo3Language);
                $this->initConfiguration();
 
                        // Creating backend template object:
@@ -1107,22 +1117,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
         * @return      string          Localized string.
         */
        public function getLLContent($string) {
-               global $LANG;
-
-               $BE_lang = $LANG->lang;
-               $BE_origCharSet = $LANG->origCharSet;
-               $BE_charSet = $LANG->charSet;
-
-               $LANG->lang = $this->contentTypo3Language;
-               $LANG->origCharSet = $LANG->csConvObj->charSetArray[$this->contentTypo3Language];
-               $LANG->origCharSet = $LANG->origCharSet ? $LANG->origCharSet : 'iso-8859-1';
-               $LANG->charSet = $this->contentTypo3Charset;
-               $LLString = $LANG->sL($string);
-
-               $LANG->lang = $BE_lang;
-               $LANG->origCharSet = $BE_origCharSet;
-               $LANG->charSet = $BE_charSet;
-               return $LLString;
+               return $this->contentLanguageService->sL($string);
        }
 
        /**