首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用locallang.xlf翻译typo3表单中的自定义validationErrorMessages

使用locallang.xlf翻译typo3表单中的自定义validationErrorMessages
EN

Stack Overflow用户
提问于 2019-07-09 22:10:08
回答 1查看 275关注 0票数 0

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

我的customform.yaml:

代码语言:javascript
复制
       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:

代码语言:javascript
复制
        <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>

有了精确的翻译密钥,它就可以工作了,除了validationErrorMessages。有人知道怎么翻译这些吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-10 03:17:44

您可以使用以下转换键作为验证错误代码。1221559976EmailAddress验证器的代码:

代码语言:javascript
复制
<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>

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

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

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

代码语言:javascript
复制
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.'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56954505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档