1

I'm new to TYPO3 and starting out with 8.7 LTS. I have created several forms with the default "form" extension. My site requires some of these forms to be translated into up to 5 other languages. So far the only solution I've found is to copy the forms and then have a separate form for each translation, but this does not seem like the best solution, as long term it would lead to form divergence.

Is it possible to add alternate translations directly in the YAML file or point to a translation file that should be used?

Heinz Schilling
  • 2,177
  • 4
  • 18
  • 35
user3201785
  • 11
  • 1
  • 2

3 Answers3

16

Here an example, like I use on a page:

For frontend translation add this to your typoscript setup:

plugin.tx_form {
  settings {
    yamlConfigurations {
        100 = EXT:my_site_package/Configuration/Yaml/CustomFormSetup.yaml
    }
  }
}

"my_site_package" has to be an existing and activated TYPO3 extension

then make an yaml file under my_site_package/Configuration/Yaml/CustomFormSetup.yaml

TYPO3:
  CMS:
    Form:
      prototypes:
        standard:
          formElementsDefinition:
            Form:
              renderingOptions:
                translation:
                  translationFile:
                    # default translation files for the frontend
                    10: 'EXT:form/Resources/Private/Language/locallang.xlf'
                    20: 'EXT:my_site_package/Resources/Private/Language/locallang.xlf'

and have some translation files in my_site_package/Resources/Private/Language

default (en): my_site_package/Resources/Private/Language/locallang.xlf

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
    <file source-language="en" datatype="plaintext" original="messages" product-name="tamods">
        <header/>
        <body>
            <trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
                <source>Object</source>
            </trans-unit>
        </body>
    </file>
</xliff>

german (de): my_site_package/Resources/Private/Language/de.locallang.xlf

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
    <file source-language="en" target-language="de" datatype="plaintext" original="messages" product-name="tamods">
        <header/>
        <body>
            <trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
                <target>Objekt</target>
            </trans-unit>
        </body>
    </file>
</xliff>

german (fr): my_site_package/Resources/Private/Language/fr.locallang.xlf

<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
    <file source-language="en" target-language="fr" datatype="plaintext" original="messages" product-name="tamods">
        <header/>
        <body>
            <trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
                <target>Objet</target>
            </trans-unit>
        </body>
    </file>
</xliff>

this is yaml from the form I am using:

renderingOptions:
  submitButtonLabel: Senden
type: Form
identifier: ticketbestellung
label: Ticketbestellung
prototypeName: standard
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'previous Step'
      nextButtonLabel: 'next Step'
    type: Page
    identifier: page-1
    label: Page
    renderables:
      -
        defaultValue: ''
        type: Text
        identifier: objekt
        label: Objekt
        properties:
          fluidAdditionalAttributes:
            placeholder: Objekt
            required: required
        validators:
          -
            identifier: NotEmpty

Some translation key, which are hard to find:

for Submit Button

element.Form.renderingOptions.submitButtonLabel element.ticketbestellung.renderingOptions.submitButtonLabel

for Subject in E-Mail finisher

finisher.Email.subject (workaround, working also before Version 8.7.5)

finisher.EmailToReceiver.subject (should be the solution was buggy till Version 8.7.5)

This answer would be not possible without the help from manuel-selbach in the TYPO3 Slack.

Martin Krung
  • 1,098
  • 7
  • 22
0

There is a (work in progress) documentation for the new Form Framework introduced with TYPO3 CMS 8 LTS.

You can find the translation docs here: https://docs.typo3.org/typo3cms/drafts/code.tritum.de/TYPO3.CMS/Form_Documentation/Concepts/FrontendRendering/Index.html#translation

Here is how you register this file: https://docs.typo3.org/typo3cms/drafts/code.tritum.de/TYPO3.CMS/Form_Documentation/Concepts/Configuration/Index.html#yaml-registration

Here you can find information about "What is a site package": https://de.slideshare.net/benjaminkott/typo3-the-anatomy-of-sitepackages

And here you can find more information about the Architecture of Extensions: https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/Index.html

Most of the form documentation (first and second link) is already translated to english, but some parts are still in german.

I know this is a lot of stuff to read, but after reading you will have a basic knowledge about "How to build a website with TYPO3 (and translate the forms).

Martin Krung
  • 1,098
  • 7
  • 22
Kevin Appelt
  • 802
  • 7
  • 14
  • 2
    Thank you. This document, like much of the TYPO3 documentation, seems to be written by and for those already largely familiar with the system. It mentions adding a key pointing to your own translation file: 20: 'EXT:my_site_package/Resources/Private/Language/locallang.xlf' But the document fails to mention where the configuration file containing the key is located in the file system or where the XLF would be located. There also seems to be a lack of description to XLF files or link leaving it to the reader to attempt to find the correct documentation for this version of TYPO3. – user3201785 Jun 22 '17 at 06:11
  • I've added some more links with background information. Hopefully this will help you. – Kevin Appelt Jun 22 '17 at 07:19
0
<?xml version="1.0" encoding="UTF-8"?>
<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
    <file source-language="en" target-language="fr" datatype="plaintext" original="messages" product-name="tamods">
        <header/>
        <body>
            <trans-unit id="ticketbestellung.element.objekt.properties.label" xml:space="preserve">
                <source>Object</source>
                <target>Objet</target>
            </trans-unit>
        </body>
    </file>
</xliff>
fuchsa
  • 17
  • 2
  • is necessary the Tag ... Object Objet ... – fuchsa Sep 28 '21 at 13:12
  • https://github.com/sebkln/form_examples/blob/master/Resources/Private/Language/de.locallang_forms_custom.xlf – fuchsa Sep 28 '21 at 13:30
  • Please don't post code-only answers. Instead, explain why it helps, and provide a link to the source for context. We're trying to educate, not just solve the immediate problem. – the Tin Man Sep 28 '21 at 19:10
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 28 '21 at 19:43