plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
254 stars 191 forks source link

No translation for add/edit form validation messages #3997

Open szakitibi opened 3 months ago

szakitibi commented 3 months ago

What I did:

Used translated version of the forms on the classic demo site:

https://classic.demo.plone.org/de/++add++Folder https://classic.demo.plone.org/de/demo/edit

Removed the title value to force a validation error.

What I expect to happen:

I expect translated pre-submit validation messages. Seems like

What actually happened:

The validation errors are not translated:

image

Please note, that the validation errors after submit are properly displayed, it is just the ones failing before form submit.

What version of Plone/ Addons I am using:

Plone 6.0.12 (6023)

I assume it runs on: plone.staticresources 2.1.14 plone.mockup 5.1.12

Possible solution:

According to the patterns validation documentation custom messages can be provided for the forms with data-pat-validation attribute. It would be possible to set the translated message strings for example in plone.app.z3cform's macros.pt

szakitibi commented 2 months ago

Note:

Although quick tests showed, that passing a translated message-required to data-pat-validation fixes the originally reported "Please fill out this field." message translation, but the proposed fix is limited to the Patternslib provided validation values only - see [1], [2].

Each browser will have its own unique set of validation messages for each html type. The set of messages for all ValidityState properties are different in each browser. It is unlikely that all the messages can be translated, unless the native validation is dropped and the backend validation with @@z3cform_validate_field calls brought back.

I'm not sure what happens when the OS and Browser is both using the selected language. Are these browser native validatoin messages translated? (E.g when the OS language is German and the browser localization is also German.)