I use locallang.xlf to translate my form (typo3 9.5.5, formextension).
my 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
-
my 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>
With an exact translation key it works, except validationErrorMessages. Does anyone know how to translate these?
You can use the following translation keys for validation error codes. 1221559976
is the code for the EmailAddress
validator:
<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>
The latter will override the first, as it contains the form identifier and is therefore more specific.
Keep in mind that both of these translation keys will not work if you already set a custom message in your form definition!
This means, the last three lines of the following example have to be removed:
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.'