Tarumi
Tarumi

Reputation: 86

Symfony 5: Translate form errors

the website I work on was developped in french(FR) and I recently developped the multilingual aspect to translate the website in english(EN), for this, I used the translator bundle. Here are my configs files :

translation.yaml

services.yaml

I also created a messages.en.xlf file with all my customs messages translated from french to english, and it works. Here is my problem : I want to translate all the default form errors.

My form with default locale: FR

My form with default locale EN

The language change has been detected and the tittle has been translated. But my error message is still the same. What can I do about it ? Do I have to manually translate all the displayed messages with some JS ? Thankx.

Upvotes: 1

Views: 1059

Answers (2)

D. Schreier
D. Schreier

Reputation: 1788

Actually, you're doing right. It's juste because this is not a Symfony message, so you can't translate it.

This message come from your browser. Only displayed when an input has required attribute.

Upvotes: 0

Leprechaun
Leprechaun

Reputation: 819

This validation and error messages come from HTML5 and language is based on your browser settings.

If you want to force english try adding this into your template:

<meta http-equiv="Content-Language" content="en">

Upvotes: 1

Related Questions