Bug #87675

form framework email2sender finisher: labels not translated correctly when vverride finisher settings is used

Added by Aurelius Hogan almost 2 years ago. Updated 11 days ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2019-02-07
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:
Remote Sprint

Description

I've got an installation with german and english localization. My forms are translated and presented in the correct language. Everything is fine except one point: The EmailToSender finischer.

It seems like

{formvh:translateElementProperty(element: formValue.element, property: 'label')}
which is used in the template file I specified in the templatePathAndFilename for the EmailToSender finisher is buggy.

The same line for EmailToReceiver finisher returns the correct translated label. But in EmailToSender finisher I get the english label no matter with which language I fill the form.

the typoscript settings

config {
    // Language Settings
    linkVars := addToList(L(0-2))
    sys_language_uid = 0
    sys_language_overlay = 1
    sys_language_mode = content_fallback
    language = de
    locale_all = de_DE.UTF-8
    htmlTag_langKey = de-DE
    # for real url
    defaultGetVars {
        L = 0
    }

    sys_language_softMergeIfNotBlank = tt_content:image, pages:media
}
[globalVar = GP:L = 1]
    config {
        sys_language_uid = 1
        language = en
        locale_all = en_EN.UTF-8
        htmlTag_langKey = en-GB
    }
[global]

[globalVar = GP:L = 2]
    config {
        sys_language_uid = 4
        language = fr
        locale_all = fr_FR.UTF-8
        htmlTag_langKey = fr-FR
    }
[global]

The localization files:
Forms.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" datatype="plaintext" original="messages" date="2018-12-03T20:38:10Z">
        <header>
            <description>Formular Labels.</description>
            <generator>LFEditor</generator>
        </header>
        <body>
            <trans-unit id="element.f_firstName.properties.label">
                <source><![CDATA[First name]]></source>
            </trans-unit>
        </body>
    </file>
</xliff>

de.Forms.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2018-12-03T20:38:10Z">
        <header>
            <description>Formular Labels.</description>
            <generator>LFEditor</generator>
        </header>
        <body>
            <trans-unit id="element.f_firstName.properties.label" approved="yes">
                <source><![CDATA[First name]]></source>
                <target><![CDATA[Vorname]]></target>
            </trans-unit>
        </body>
    </file>
</xliff>

The form definition:


renderingOptions:
  submitButtonLabel: 'Anfrage absenden ...'
type: Form
identifier: ...Konfigurator
label: '...Konfigurator'
prototypeName: ...KonfiguratorBase
finishers:
  -
    options:
      ...
      templatePathAndFilename: '.../Customer.html'
    identifier: EmailToSender
  -
    options:
      ...
      templatePathAndFilename: '.../Company.html'
    identifier: EmailToReceiver
  -
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'Previous step'
      nextButtonLabel: 'Neue Seite'
    type: Page
    identifier: page-1
    label: ''
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: f_firstName
        label: Vornamen!!!123
        properties:
          fluidAdditionalAttributes:
            required: required
          elementDescription: given-name
        validators:
          -
            identifier: NotEmpty

the Template file: company.html and customer.html are identical:

{namespace formvh=TYPO3\CMS\Form\ViewHelpers}
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<html xmlns:f="https://xsd.helhum.io/ns/typo3/cms-fluid/master/ViewHelpers" 
      xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" 
      xmlns:formvh="http://typo3.org/ns/TYPO3/CMS/Form/ViewHelpers" data-namespace-typo3-fluid="true">
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="format-detection" content="telephone=no">
</head>
<body>
    <table width="600" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td colspan="2" width="1200" align="left">
                <f:render section="replacePlaceholders" arguments="{form:form, uid:'EmailIntro'}"/> <br/>
            </td>
        </tr>
        <formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue">
            <tr>
                <td width="600" valign="top" align="left">{formvh:translateElementProperty(element: formValue.element, property: 'label')}</td>
                <td width="600" valign="top" align="left">
                    <f:if condition="{formValue.value}">
                        <f:then>
                            <f:if condition="{formValue.isMultiValue}">
                                <f:then>
                                    <table cellspacing="0" border="0">
                                        <f:for each="{formValue.processedValue}" as="value">
                                            <tr>
                                                <td>{value}</td>
                                            </tr>
                                        </f:for>
                                    </table>
                                </f:then>
                                <f:else>
                                    <table cellspacing="0" border="0">
                                        <tr>
                                            <td><f:format.nl2br>{formValue.processedValue}</f:format.nl2br></td>
                                        </tr>
                                    </table>
                                </f:else>
                            </f:if>
                        </f:then>
                        <f:else>
                            -
                        </f:else>
                    </f:if>
                </td>
            </tr>
        </formvh:renderAllFormValues>
        <tr>
            <td colspan="2" width="1200" align="left"> <br/>
                <f:render section="replacePlaceholders" arguments="{form:form, uid:'EmailOutro'}"/>
            </td>
        </tr>
    </table>
</body>

<f:section name="replacePlaceholders">
    <v:variable.set name="messageUid" value="{v:variable.typoscript(path: 'plugin.tx_form.settings.UIDs.{form.identifier}.{uid}')}"/>
    <v:variable.set name="message" value="{v:content.render(contentUids:{0:messageUid})}"/>

    <formvh:renderAllFormValues renderable="{form.formDefinition}" as="formValue">
        <v:variable.set name="message">
            <v:format.replace content="{message}" 
                              substring="[{formValue.element.identifier}]" 
                              replacement="{formValue.processedValue}"/>
        </v:variable.set>
    </formvh:renderAllFormValues>
    <f:format.raw>{message}</f:format.raw>
</f:section>
</html>

Summary:

All contents and translation in EmailToReceiver is correct in both languages. EmailToSender form labels are always english. Everything else is correct.

Is there a configuration error?

#1

Updated by Bjoern Jacob over 1 year ago

  • Sprint Focus set to Remote Sprint
#2

Updated by Susanne Moog over 1 year ago

  • Status changed from New to In Progress
  • Assignee set to Daniela Pohl
#3

Updated by Daniela Pohl over 1 year ago

  • Status changed from In Progress to New
  • Assignee deleted (Daniela Pohl)

I can not reproduce the issue.

Set up german and english localization, created a form with emailToSender and emailToReceiver finishers and used the company.html to overwrite the Template Path. Labels are always in correct language.

form.yaml


renderingOptions:
  submitButtonLabel: Submit
type: Form
identifier: test
label: Test
prototypeName: standard
finishers:
  -
    options:
      subject: test
      ...
      templatePathAndFilename: 'Customer.html'
    identifier: EmailToSender
  -
    options:
      subject: testm
      ...
      templatePathAndFilename: 'Company.html'
    identifier: EmailToReceiver
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'Previous step'
      nextButtonLabel: 'Next step'
    type: Page
    identifier: page-1
    label: ''
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: f_firstName
        label: Vorname!
        properties:
          elementDescription: ''

locallang.xlf

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
    <file t3:id="1475977066" source-language="en" datatype="plaintext" original="messages" date="2016-10-09T03:38:32Z" product-name="form">
        <header/>
        <body>
            <trans-unit id="element.f_firstName.properties.label">
                <source><![CDATA[First name in english]]></source>
            </trans-unit>
        </body>
    </file>
</xliff>

de.locallang.xlf

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.0">
    <file source-language="en" target-language="de" datatype="plaintext" original="messages" date="2018-12-03T20:38:10Z">
        <header>
            <description>Formular Labels.</description>
            <generator>LFEditor</generator>
        </header>
        <body>
            <trans-unit id="element.f_firstName.properties.label" approved="yes">
                <source><![CDATA[First name in englisch]]></source>
                <target><![CDATA[Vorname in deutsch]]></target>
            </trans-unit>
        </body>
    </file>
</xliff>

#4

Updated by Bjoern Jacob over 1 year ago

  • Status changed from New to Needs Feedback
  • Assignee set to Aurelius Hogan

Aurelius, as you can see we cannot reproduce the issue. Can you further test your installation and provide us with more insight (installed extensions etc.)? Do you use the bootstrap package?

#5

Updated by Bjoern Jacob over 1 year ago

  • Sprint Focus deleted (Remote Sprint)
#6

Updated by Jürgen Venne over 1 year ago

I've the same issue here on a multidomain (3 sites), multilanguage (15 languages) site.
It breaks down to the RenderingOptions in TranslateElementPropertyViewHelper.
The RenderingOptions are null so no language can be determined and the default english labels are rendered.

As a workaround I use this Fluid code:

<f:variable name="lll" value="LLL:EXT:fancysitepackage/Resources/Private/Extensions/form/language/locallang.xlf" />
<f:translate key='{lll}:contactform.element.{formValue.element.identifier}.properties.label' default="{formValue.element.identifier}" />

#7

Updated by Susanne Moog about 1 year ago

  • Sprint Focus set to Remote Sprint
#8

Updated by Bjoern Jacob about 1 year ago

  • Sprint Focus deleted (Remote Sprint)
#9

Updated by Bjoern Jacob 8 months ago

  • Status changed from Needs Feedback to New
  • Assignee deleted (Aurelius Hogan)
  • Sprint Focus set to Remote Sprint

Let's check this again and see what Jürgen did :) If this only occurs on v8 we will not fix the issue (v8 is in ELTS phase now).

#10

Updated by Jarvis H 7 months ago

I too can confirm this issue and in Typo3 9.5.14.

After checking through all the source code translation steps, I discovered that the problem has to do with the flexform finisher override settings.

When I activate the "Override finisher settings" option in the plugin, the following is added to the saved flexform data:

<field index="settings.finishers.EmailToReceiver.translation.language">
    <value index="vDEF">Default</value>
</field>

Internally this causes the value of $languageKey in TYPO3\CMS\Form\Service\TranslationService to be set to 'Default' which of course is not valid, hence the e-mail translations are shown in the wrong language. (Note: the value is dependent on your current BE-language in Typo3, so if switching to German, the saved value becomes 'Standard' instead of 'Default')

If changing the saved flexform data to this, or simply not overriding the finisher settings at all, the problem goes away:

<field index="settings.finishers.EmailToReceiver.translation.language">
    <value index="vDEF"></value>
</field>

What I don't understand however is why this flexform setting is rendered as a select field at all, or rather how is it supposed to be used?

Hope this helps any further debugging of the issue.

#11

Updated by Jarvis H 7 months ago

EDIT adding additional information:

(I am not completely sure if my issue is the same as for the other people in this thread.)

To further clarify, I tracked down the translation label in my local var/labels/de/form/Resources/Private/Language/de.Database.xlf. Oddly enough it states as note: "This label is deprecated (not used anymore) since TYPO3v8" which is not true as it is used as translation for settings.finishers.EmailToReceiver.translation.language when enabling the "Override finisher settings" option and using the EmailToReceiver finisher. This would indicate that a translation of a select field option value is inadvertently taking place.

<trans-unit id="default" resname="default" xml:space="preserve" approved="yes">
    <source>Default</source>
    <target state="translated">Standard</target>
    <note>This label is deprecated (not used anymore) since TYPO3v8</note>
    <alt-trans xml:space="preserve" origin="cicom">
        <target>Vorgabe</target>
    </alt-trans>
</trans-unit>

I also tested how translations are working in EmailToSender and noticed, that there is an additional bug at play here. Any language settings for EmailToReceiver (i.e. forcing a language for any labels in the receiver mail, fx. always setting receiver mails to be german regardless of FE-language) will also be used in EmailToSender. As far as I can tell the reason for this is, they both use TYPO3\CMS\Form\Service\TranslationService which is a singleton. TYPO3\CMS\Form\Domain\Finishers\EmailFinisher uses the TranslationService->setLanguage method and any value set here is then also used in EmailToSender.

It feels like this singleton should not have such a getter method, as it causes unforeseen consequences in other locations.

#12

Updated by Axel Hahn 11 days ago

  • Subject changed from form framework email2sender finisher: labels not translated to form framework email2sender finisher: labels not translated correctly when vverride finisher settings is used
  • TYPO3 Version changed from 8 to 9

I am facing the same problem with typo3 version 9.5.23.
My translations used in the EmailToSender / EmailToReceiver finishers are working as expected until I set the "Override finisher settings" option to true.
All elements which are translated by using

 {formvh:translateElementProperty(element: formValue.element, property: 'placeholder')}

are shown in the default language instead of the selected one.
Whereas elements which are translated by using
<f:translate key="LLL:EXT:my_site_package/Resources/Private/Language/locallang_forms_email.xlf:email.yes"/>

are translated correctly.

Also available in: Atom PDF