Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add FlexForm field support #285

Open
ErHaWeb opened this issue Jul 12, 2023 · 10 comments
Open

[FEATURE] Add FlexForm field support #285

ErHaWeb opened this issue Jul 12, 2023 · 10 comments
Labels
enhancement New feature or request

Comments

@ErHaWeb
Copy link
Contributor

ErHaWeb commented Jul 12, 2023

Is your feature request related to a problem? Please describe.
Currently it is not possible to translate fields defined in FlexForms. In some cases, translation-relevant information is also located there. This case can occur in the context of grid elements that use FlexForms or plugins that expect text input in the plugin options like Powermail.

Describe the solution you'd like
I would like to have the ability to configure which FlexForm field contents should be translated. This is currently only configurable at database table field level.

Describe alternatives you've considered
I have already tried setting $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['l10n_mode'] = 'prefixLangTitle'; to have the FlexForm translated as a whole. However, this configuration does not seem to have any effect on the resulting texts.

As a plugin developer, the workaround is to migrate the FlexForm fields to database table fields to use the translation feature there as well.

Additional context
For example, I tried to translate the following flexform from English to German with the setting $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['l10n_mode'] = 'prefixLangTitle';. As a result, there was no discrepancy in the translated content at all in your extension.

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
    <data>
        <sheet index="sDEF">
            <language index="lDEF">
                <field index="subtitle">
                    <value index="vDEF"></value>
                </field>
                <field index="text">
                    <value index="vDEF">Soak up the atmosphere of a unique hystorical site.</value>
                </field>
                <field index="button_text">
                    <value index="vDEF">About the Resort</value>
                </field>
                <field index="color">
                    <value index="vDEF">light</value>
                </field>
                <field index="link">
                    <value index="vDEF">t3://page?uid=296438</value>
                </field>
            </language>
        </sheet>
    </data>
</T3FlexForms>

In contrast, if I enter the same FlexForm directly in the DeepL app, both the content and the attributes are translated. The latter would affect the functionality and is a reason that the scope would really need to be on the content of the individual FlexForm fields to meet the requirement.

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3FlexForms>
    <Daten>
        <Blatt index="sDEF">
            <Sprache index="lDEF">
                <feld index="untertitel">
                    <value index="vDEF"></value>
                </field>
                <feld index="text">
                    <value index="vDEF">Saugen Sie die Atmosphäre eines einzigartigen hystorischen Ortes auf.</value>
                </field>
                <field index="button_text">
                    <value index="vDEF">Über das Resort</value>
                </field>
                <field index="color">
                    <value index="vDEF">Hell</value>
                </field>
                <feld index="link">
                    <value index="vDEF">t3://page?uid=296438</value>
                </field>
            </language>
        </sheet>
    </data>
</T3FlexForms>
@ErHaWeb ErHaWeb added the enhancement New feature or request label Jul 12, 2023
@calien666
Copy link
Member

As we currently use the translation hook inside the DataHandler, it's not possible at the moment to allow translations of flexforms.
The hook only provides support for text and input fields, which are defined as text or input in TCA.
That's the reason, we don't support translation.s for dce or flux, as these extensions save their content in TCA type flex.
If you have an idea, how to fix, your'e welcome to contribute

@ErHaWeb
Copy link
Contributor Author

ErHaWeb commented Jul 17, 2023

Yes, referring to the following hook you are right:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processTranslateToClass']

At this point I don't see a way either (except XCLASS). The condition in the DataHandler
https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Classes/DataHandling/DataHandler.php#L4923-L4932
ensures that the hook is only executed for fields of type text, input, email and link as well as the l10n_mode="prefixLangTitle".

However, on closer inspection I found another hook that could be used here:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['checkFlexFormValue']

with method name checkFlexFormValue_beforeMerge. This method is called with three parameters $this, $currentValueArray and $arrValue, which can be used to modify the resulting Flexform XML (e.g. insert translations from a service).

Within the method, the following condition could be used to check if it is one of the 4 actions of EXT:wv_deepltranslate. This is necessary because the hook is also executed on when creating new elements and when editing existing elements outside the translation process.

$action = $GLOBALS['TYPO3_REQUEST']->getQueryParams() ? $GLOBALS['TYPO3_REQUEST']->getQueryParams()['action'] : '';
if(in_array($action, ['localizedeepl', 'localizedeeplauto', 'localizegoogle', 'localizegoogleauto'])){
/* ... Interpretation of FlexForms and translation of FlexForm fields is performed here ... */
}

Is this an approach that could be taken further or have I overlooked an essential aspect?

@calien666
Copy link
Member

@ErHaWeb Okay, this should be a possible solution. For the moment, there is no idea to add features to version 3 anymore, but we will take it as feature to version 4.

@ErHaWeb
Copy link
Contributor Author

ErHaWeb commented Jul 22, 2023

Great, glad to read that 👍

@peterbenke
Copy link

@calien666
This is very good news 👍
Can you say when version 4 will be released?
Possibly end of March 2024, when TYPO3 11 LTS expires?
Thank you very much for your great work.

@calien666
Copy link
Member

@peterbenke We currently HAVE a version 4, which is available for TYPO3 v11 and v12. But, as we have a lot of hours spent here, web-vision decided to release version 4 as EAP: https://www.web-vision.de/en/automatic-translations-with-typo3-wv-deepltranslate-early-access-programme-launched.html
Additionally, we have published the roadmap for the next steps with this extension: https://www.web-vision.de/en/deepl-translate-for-typo3-development-outlook.html

@peterbenke
Copy link

@calien666
Thank you very much.
And this EAP version includes translations for flexforms too?
Is this Early-Acces-Program also valid for 2024?

@calien666
Copy link
Member

@peterbenke The flexform feature is not included yet, as we are looking for sponsors.
EAP is also valid for 2024 and includes the extension "Enable translated content", which easily enables all translated content elements according to enabled original content elements by only one click.
Currently planned are mass translation, auto translation and re-translation. All these extensions are EAP only and will have no public release.

For more information, feel free to contact @borishinzer (b.hinzer@web-vision.de)

@peterbenke
Copy link

@calien666 Thank you

@peterbenke
Copy link

@calien666
Do you know, when the flexform feature will be available?
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants