How to have a translation of the validation error messages with package “Laravel-Lang”?

  Kiến thức lập trình

I would like to translate my error messages with Laravel 11.

I spotted this very reputable repository.

I installed it and added the “fr” translations.

When I trigger an error with the “en” locale, then I get a very clean, understandable error message. Example:

"last_name": [
        "The last name field must not be greater than 50 characters."
    ]

When I trigger the same error with the “fr” locale, then I have a message translated into French, but the attribute is also translated. Example:

"last_name": [
            "Le texte de nom ne peut pas contenir plus de 50 caractères."
   ]

Which no longer means anything. I was expecting a translation like this

Le champ last name ne peut pas contenir plus de 50 caractères.

My question: how to prohibit this translation of the attribute?

It’s not easy to explain this translation issue in English with examples in French, I hope my explanations are clear.

LEAVE A COMMENT