[BUGFIX] TS/EM constant categories cannot be localized 03/28903/7
authorXavier Perseguers <xavier@typo3.org>
Thu, 27 Mar 2014 10:40:51 +0000 (11:40 +0100)
committerXavier Perseguers <xavier@typo3.org>
Wed, 11 Jun 2014 21:31:49 +0000 (23:31 +0200)
Constant categories may now be localized using a construct similar
to defining custom subcategories:

Fixes: #57369
Documentation: #57371
Releases: 6.2
Change-Id: I6bea094d98897756772a6f616c8a2f3ab5fe7844
Reviewed-on: https://review.typo3.org/28903
Reviewed-by: Wouter Wolters
Reviewed-by: Fabien Udriot
Tested-by: Fabien Udriot
Tested-by: Wouter Wolters
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php

index edcde7b..934146e 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Core\TypoScript;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  (c) 1999-2014 Kasper Skårhøj (kasperYYYY@typo3.com)
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -68,6 +68,13 @@ class ExtendedTemplateService extends \TYPO3\CMS\Core\TypoScript\TemplateService
                'all' => array()
        );
 
+       /**
+        * Translated categories
+        *
+        * @var array
+        */
+       protected $categoryLabels = array();
+
        // This will be filled with the available categories of the current template.
        /**
         * @todo Define visibility
@@ -910,7 +917,11 @@ class ExtendedTemplateService extends \TYPO3\CMS\Core\TypoScript\TemplateService
                                                                        case 'cat':
                                                                                // List of categories.
                                                                                $catSplit = explode('/', strtolower($keyValPair[1]));
-                                                                               $editableComments[$const]['cat'] = trim($catSplit[0]);
+                                                                               $catSplit[0] = trim($catSplit[0]);
+                                                                               if (isset($this->categoryLabels[$catSplit[0]])) {
+                                                                                       $catSplit[0] = $this->categoryLabels[$catSplit[0]];
+                                                                               }
+                                                                               $editableComments[$const]['cat'] = $catSplit[0];
                                                                                // This is the subcategory. Must be a key in $this->subCategories[]. catSplit[2] represents the search-order within the subcat.
                                                                                $catSplit[1] = trim($catSplit[1]);
                                                                                if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) {
@@ -924,6 +935,14 @@ class ExtendedTemplateService extends \TYPO3\CMS\Core\TypoScript\TemplateService
                                                                                // Label
                                                                                $editableComments[$const]['label'] = trim($keyValPair[1]);
                                                                                break;
+                                                                       case 'customcategory':
+                                                                               // Custom category label
+                                                                               $customCategory = explode('=', $keyValPair[1], 2);
+                                                                               if (trim($customCategory[0])) {
+                                                                                       $categoryKey = strtolower($customCategory[0]);
+                                                                                       $this->categoryLabels[$categoryKey] = $GLOBALS['LANG']->sL($customCategory[1]);
+                                                                               }
+                                                                               break;
                                                                        case 'customsubcategory':
                                                                                // Custom subCategory label
                                                                                $customSubcategory = explode('=', $keyValPair[1], 2);