forms - 使用 locallang.xlf 以typo3 形式翻译自定义validationErrorMessages
问题描述
我使用 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>
除了validationErrorMessages之外,它可以使用精确的翻译密钥。有谁知道如何翻译这些?
解决方案
您可以将以下翻译键用于验证错误代码。1221559976
是EmailAddress
验证器的代码:
<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.'
推荐阅读
- vue.js - 在构建部署到 S3 后获取环境变量是 Vuejs
- android - 使用改造时如何更新 RecyclerView?
- powerbi - PowerBI DAX Measure 不拾取行
- c - 如何在C中打印指向哪个指针成员的值
- php - Symfony 4.26 / php 7.4.9 - 找不到驱动程序
- sql - 如何在不使用窗口函数 Oracle 的情况下获取每组的第一行?
- testing - 什么是好的进程 I/O 速率?
- python - 改进我的“matplotlib.pyplot”语法以按目标散点图
- docker - 如何在 mcr.microsoft.com/dotnet/core/sdk:3.1 中运行 Windows 服务?
- python - 为什么不能在 django admin 中隐藏 slug 字段?