Bug #77506

The default translate to message does not work for more than one localizable field with prefixLangTitle flag per table

Added by M. Stichweh about 3 years ago. Updated 11 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Localization
Target version:
-
Start date:
2016-08-15
Due date:
% Done:

100%

TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

If an object has more than one field with the prefixLangTitle flag enabled, only the first one will have a correct prefix after localize the object. All further fields will only get empty brakets ([]) as prefix.
The problem seems to be that the $translateToMsg variable is not reset within the foreach loop in the localize method (DataHandler - Line 4636). So it will be reused in next loop and set to $TSConfig['translateToMessage'] which is empty by default:

public function localize($table, $uid, $language)
{
    ...    
    // Set exclude Fields:
    foreach ($GLOBALS['TCA'][$Ttable]['columns'] as $fN => $fCfg) {
        // Check if we are just prefixing:
        if ($fCfg['l10n_mode'] == 'prefixLangTitle') {
            if (($fCfg['config']['type'] == 'text' || $fCfg['config']['type'] == 'input') && (string)$row[$fN] !== '') {
                list($tscPID) = BackendUtility::getTSCpid($table, $uid, '');
                $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
                if (!empty($TSConfig['translateToMessage'])) {
                    $translateToMsg = $GLOBALS['LANG'] ? $GLOBALS['LANG']->sL($TSConfig['translateToMessage']) : $TSConfig['translateToMessage'];
                    $translateToMsg = @sprintf($translateToMsg, $langRec['title']);
                }
                if (empty($translateToMsg)) {
                    $translateToMsg = 'Translate to ' . $langRec['title'] . ':';
                } else {
                    $translateToMsg = @sprintf($TSConfig['translateToMessage'], $langRec['title']);
                }
                $overrideValues[$fN] = '[' . $translateToMsg . '] ' . $row[$fN];
            }
        }
        ...

Reset the variable should solve this issue:

public function localize($table, $uid, $language)
{
    ...    
    // Set exclude Fields:
    foreach ($GLOBALS['TCA'][$Ttable]['columns'] as $fN => $fCfg) {
        // Check if we are just prefixing:
        if ($fCfg['l10n_mode'] == 'prefixLangTitle') {
            if (($fCfg['config']['type'] == 'text' || $fCfg['config']['type'] == 'input') && (string)$row[$fN] !== '') {
                $translateToMsg = '';
                list($tscPID) = BackendUtility::getTSCpid($table, $uid, '');
                $TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
                if (!empty($TSConfig['translateToMessage'])) {
                    $translateToMsg = $GLOBALS['LANG'] ? $GLOBALS['LANG']->sL($TSConfig['translateToMessage']) : $TSConfig['translateToMessage'];
                    $translateToMsg = @sprintf($translateToMsg, $langRec['title']);
                }
                if (empty($translateToMsg)) {
                    $translateToMsg = 'Translate to ' . $langRec['title'] . ':';
                } else {
                    $translateToMsg = @sprintf($TSConfig['translateToMessage'], $langRec['title']);
                }
                $overrideValues[$fN] = '[' . $translateToMsg . '] ' . $row[$fN];
            }
        }
        ...

As workaround the translateToMessage has to be set explicitly in the page TSConfig:

TCEMAIN {
  translateToMessage = Translate to %s
}

Associated revisions

Revision d8450b78 (diff)
Added by Georg Ringer almost 3 years ago

[BUGFIX] Fix message "Translate to"

Reset the variable to be able to set the text "Translate to" for
multiple fields.

Resolves: #77506
Releases: master, 7.6
Change-Id: I6b18f30ece04ae5cf5710617dbbc5ea2c0855ad6
Reviewed-on: https://review.typo3.org/49499
Tested-by: Bamboo TYPO3com <>
Reviewed-by: Stefan Neufeind <>
Tested-by: Stefan Neufeind <>
Reviewed-by: Joerg Boesche <>
Tested-by: Joerg Boesche <>
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

Revision 343e3c74 (diff)
Added by Georg Ringer almost 3 years ago

[BUGFIX] Fix message "Translate to"

Reset the variable to be able to set the text "Translate to" for
multiple fields.

Resolves: #77506
Releases: master, 7.6
Change-Id: I6b18f30ece04ae5cf5710617dbbc5ea2c0855ad6
Reviewed-on: https://review.typo3.org/49522
Reviewed-by: Christian Kuhn <>
Tested-by: Christian Kuhn <>

History

#1 Updated by Riccardo De Contardi about 3 years ago

I think that's the same issue as #68272

#2 Updated by Gerrit Code Review about 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/49499

#3 Updated by Gerrit Code Review almost 3 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/49522

#4 Updated by Georg Ringer almost 3 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#5 Updated by Benni Mack 11 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF