简体   繁体   English

您如何在 TYPO3 CMS 8.7 LTS 中翻译 EXT:Form forms?

[英]How do you translate EXT:Form forms in TYPO3 CMS 8.7 LTS?

I'm new to TYPO3 and starting out with 8.7 LTS.我是 TYPO3 的新手,从 8.7 LTS 开始。 I have created several forms with the default "form" extension.我创建了几个带有默认“表单”扩展名的 forms。 My site requires some of these forms to be translated into up to 5 other languages.我的网站要求将其中一些 forms 翻译成最多 5 种其他语言。 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.到目前为止,我找到的唯一解决方案是复制 forms 然后为每个翻译都有一个单独的表格,但这似乎不是最好的解决方案,因为从长远来看它会导致表格分歧。

Is it possible to add alternate translations directly in the YAML file or point to a translation file that should be used?是否可以直接在YAML文件中添加替代翻译或者指向一个应该使用的翻译文件?

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 “ my_site_package”必须是现有的并激活的TYPO3扩展

then make an yaml file under my_site_package/Configuration/Yaml/CustomFormSetup.yaml 然后在my_site_package / Configuration / Yaml / CustomFormSetup.yaml下制作一个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 并在my_site_package / Resources / Private / Language中有一些翻译文件

default (en): my_site_package/Resources/Private/Language/locallang.xlf 默认值(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 德语(de):my_site_package /资源/私人/语言/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 德语(fr):my_site_package /资源/私人/语言/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: 这是我使用的形式的Yaml:

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 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.Email.subject (解决方法,也可以在版本8.7.5之前运行)

finisher.EmailToReceiver.subject (should be the solution was buggy till Version 8.7.5 ) finisher.EmailToReceiver.subject直到版本8.7.5之前 ,解决方案都是错误的

This answer would be not possible without the help from manuel-selbach in the TYPO3 Slack. 没有TYPO3 Slack中的manuel-selbach的帮助,这个答案是不可能的。

There is a (work in progress) documentation for the new Form Framework introduced with TYPO3 CMS 8 LTS. 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 您可以在这里找到翻译文档: 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 这是您注册此文件的方式: 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 在这里,您可以找到有关“什么是网站包”的信息: 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 在这里,您可以找到有关扩展架构的更多信息: 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). 我知道这是很多东西,但是阅读之后,您将具有有关“如何使用TYPO3建立网站(以及翻译表格)的基本知识。

<?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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM