【问题标题】:Translate custom validationErrorMessages in typo3 forms with locallang.xlf使用 locallang.xlf 以typo3 形式翻译自定义validationErrorMessages
【发布时间】:2019-07-09 14:10:07
【问题描述】:

我使用 locallang.xlf 来翻译我的表单(typo3 9.5.5,formextension)。

我的 customform.yaml:

       renderables:
          -
            properties:
              fluidAdditionalAttributes:
                required: required
              validationErrorMessages:
                -
                  code: 1221560910
                  message: 'My Custom Message'
                  code: 1221560718
                  message: 'My Custom Message'
                -
                  code: 1347992400
                  message: 'My Custom Message'
                -
                  code: 1347992400
                  message: 'My Custom Message'
              options:
                products: 'Products'
                miscellaneous: 'Sonstiges'
              prependOptionLabel: 'Please Specify'
            type: SingleSelect
            identifier: subject
            label: 'Your Subject:'
            validators:
              -
                identifier: NotEmpty
          -

我的 locallang.xlf:

        <trans-unit id="element.subject.properties.prependOptionLabel">
            <source>Please Specify --Works!</source>
        </trans-unit>
        <trans-unit id="element.subject.properties.options.products">
                <source>Products --Works!</source>
        </trans-unit>
    <trans-unit id="element.subject.properties.validationErrorMessages.message">
            <source>Custom Message -Doesn't work!</source>
        </trans-unit>

除了v​​alidationErrorMessages之外,它可以使用精确的翻译键。 有人知道怎么翻译吗?

【问题讨论】:

    标签: forms validation typo3 translation typo3-9.x


    【解决方案1】:

    您可以使用以下翻译键来验证错误代码。 1221559976EmailAddress 验证器的代码:

    <trans-unit id="validation.error.1221559976">
        <source>Please enter valid email address. Thanks!</source>
        <target>Bitte gebe eine gültige E-Mail-Adresse ein. Danke!</target>
    </trans-unit>
    <trans-unit id="MyContactForm.validation.error.1221559976">
        <source>Please enter valid email address. Thank you very much!</source>
        <target>Bitte gebe eine gültige E-Mail-Adresse ein. Vielen herzlichen Dank!</target>
    </trans-unit>
    

    后者将覆盖第一个,因为它包含表单标识符,因此更具体。

    请记住,如果您已经在表单定义中设置了自定义消息,这两个翻译键都将不起作用!

    这意味着,必须删除以下示例的最后三行:

    renderables:
      -
        defaultValue: ''
        identifier: email
        label: Email
        type: Text
        properties:
          fluidAdditionalAttributes:
            placeholder: 'Email address'
          ### Don't set this if you want to translate the message:
          #validationErrorMessages:
          #  - code: 1221559976
          #    message: 'Please enter a valid email address, dear.'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-17
      • 2013-04-26
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 1970-01-01
      相关资源
      最近更新 更多