Project

General

Profile

Actions

Bug #77506

closed

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

Added by M. Stichweh over 7 years ago. Updated over 5 years ago.

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

100%

Estimated time:
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
}
Actions #1

Updated by Riccardo De Contardi over 7 years ago

I think that's the same issue as #68272

Actions #2

Updated by Gerrit Code Review over 7 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

Actions #3

Updated by Gerrit Code Review over 7 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

Actions #4

Updated by Georg Ringer over 7 years ago

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

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF