[BUGFIX] CKEditor: Configuration properties not translatable 40/52640/2
authorThorben Nissen <thorben.nissen@kapp-hamburg.de>
Thu, 20 Apr 2017 12:20:19 +0000 (14:20 +0200)
committerBenni Mack <benni@typo3.org>
Thu, 27 Apr 2017 14:19:17 +0000 (16:19 +0200)
Adding custom stylesSets it is not possible to use "LLL:..." syntax. I
would be just display as is.

Add recursive resolving of "LLL:..." references in the configuration
properties.

Resolves: #80914
Releases: master, 8.7
Change-Id: I5c65f54cc3cc15cc4950df200828b48e124325f3
Reviewed-on: https://review.typo3.org/52640
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php

index f485c41..6f92942 100644 (file)
@@ -230,6 +230,24 @@ class RichTextElement extends AbstractFormElement
     }
 
     /**
+     * Add configuration to replace LLL: references with the translated value
+     * @param array $configuration
+     *
+     * @return array
+     */
+    protected function replaceLanguageFileReferences(array $configuration): array
+    {
+        foreach ($configuration as $key => $value) {
+            if (is_array($value)) {
+                $configuration[$key] = $this->replaceLanguageFileReferences($value);
+            } elseif (is_string($value) && stripos($value, 'LLL:') === 0) {
+                $configuration[$key] = $this->getLanguageService()->sL($value);
+            }
+        }
+        return $configuration;
+    }
+
+    /**
      * Add configuration to replace absolute EXT: paths with relative ones
      * @param array $configuration
      *
@@ -240,7 +258,7 @@ class RichTextElement extends AbstractFormElement
         foreach ($configuration as $key => $value) {
             if (is_array($value)) {
                 $configuration[$key] = $this->replaceAbsolutePathsToRelativeResourcesPath($value);
-            } elseif (is_string($value) && substr($value, 0, 4) === 'EXT:') {
+            } elseif (is_string($value) && stripos($value, 'EXT:') === 0) {
                 $configuration[$key] = $this->resolveUrlPath($value);
             }
         }
@@ -282,7 +300,9 @@ class RichTextElement extends AbstractFormElement
         }
         $configuration['contentsLanguage'] = $this->getLanguageIsoCodeOfContent();
 
-        // replace all paths
+        // Replace all label references
+        $configuration = $this->replaceLanguageFileReferences($configuration);
+        // Replace all paths
         $configuration = $this->replaceAbsolutePathsToRelativeResourcesPath($configuration);
 
         // there are some places where we define an array, but it needs to be a list in order to work