问题
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?
回答1:
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.
回答2:
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).
来源:https://stackoverflow.com/questions/44628751/how-do-you-translate-extform-forms-in-typo3-cms-8-7-lts