[BUGFIX] Add fieldname to DataHandler translateToMessage hook 57/56957/13
authorRicky <ricky.mk@pitsolutions.com>
Mon, 14 May 2018 06:50:47 +0000 (12:20 +0530)
committerTobi Kretschmann <tobi@tobishome.de>
Fri, 12 Jul 2019 07:48:16 +0000 (09:48 +0200)
This patch adds a fieldname parameter to the DataHandler localize
translateToMessage hook. The fieldname helps hook objects to
identify the currently processed field.

Thus based on the field, the hook can make some decisions on translate.

Resolves: #84844
Releases: master, 9.5, 8.7
Change-Id: If7b05f017ed1cdbc777d8cda18fce84f9a01ac04
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/56957
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Steffen Frese <steffenf14@gmail.com>
Tested-by: Julian Geils <j_geils@web.de>
Tested-by: Dieter Porth <d.porth@neusta.de>
Tested-by: Jörg Bösche <typo3@joergboesche.de>
Reviewed-by: Dieter Porth <d.porth@neusta.de>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Julian Geils <j_geils@web.de>
Reviewed-by: Jan Stockfisch <typo3@jan-stockfisch.de>
Reviewed-by: Jörg Bösche <typo3@joergboesche.de>
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Documentation/Changelog/8.5/Feature-67909-AddHookToDataHandler-Localize-TranslateToMessage.rst
typo3/sysext/core/Documentation/Changelog/8.7.x/Important-84844-AddFieldnameToDataHandler-Localize-TranslateToMessageHook.rst [new file with mode: 0644]

index bdfc64a..8aa9327 100644 (file)
@@ -4354,7 +4354,7 @@ class DataHandler implements LoggerAwareInterface
                     foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processTranslateToClass'] ?? [] as $className) {
                         $hookObj = GeneralUtility::makeInstance($className);
                         if (method_exists($hookObj, 'processTranslateTo_copyAction')) {
-                            $hookObj->processTranslateTo_copyAction($row[$fN], $langRec, $this);
+                            $hookObj->processTranslateTo_copyAction($row[$fN], $langRec, $this, $fN);
                         }
                     }
                     if (!empty($translateToMsg)) {
index ef474f4..ff09483 100644 (file)
@@ -28,9 +28,14 @@ Implement it for example as follows:
 .. code-block:: php
 
        class YourHookClass {
-               public function processTranslateTo_copyAction(&$content, $lang, $dataHandler) {
+               public function processTranslateTo_copyAction(&$content, $lang, $dataHandler, $fieldName) {
                        // Do something with content (translate, transliterate etc)
                }
        }
 
-.. index:: PHP-API, Backend
\ No newline at end of file
+Note
+======
+
+Since Version 8.7.16 hooks now get a fourth parameter for the currently processed fieldname.
+
+.. index:: PHP-API, Backend
diff --git a/typo3/sysext/core/Documentation/Changelog/8.7.x/Important-84844-AddFieldnameToDataHandler-Localize-TranslateToMessageHook.rst b/typo3/sysext/core/Documentation/Changelog/8.7.x/Important-84844-AddFieldnameToDataHandler-Localize-TranslateToMessageHook.rst
new file mode 100644 (file)
index 0000000..904e98b
--- /dev/null
@@ -0,0 +1,14 @@
+.. include:: ../../Includes.txt
+
+=====================================================================================
+Important: #84844 - Add fieldname to DataHandler - localize - translateToMessage hook
+=====================================================================================
+
+See :issue:`84844`
+
+Description
+===========
+
+The `translateToMessage` hooks of the :php`localize()` function of the :php:`DataHandler` now get a fourth parameter for the currently processed fieldname.
+
+.. index:: Backend, PHP-API