[5.7] Show displayable values for relative dates in validation error messages #27341
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently the
after
,after_or_equal
,before
,before_or_equal
anddate_equals
validation rules allow us to use relative keywords in english to compare dates, e.g.date_equals:tomorrow
.When the placeholders are replaced in the validation messages, the
:date
parameter is normally replaced if it references another attribute, e.g.after:start_date
but not when it's a relative keyword.This is an issue when the locale is other than english: e.g. the
date_equals:tomorrow
in french is translated toLe champ date doit être une date égale à tomorrow.
This commit allows for developers to specify custom translation for these values.
E.g. in
fr/validation.php
:So now the validation message will be translated to
Le champ date doit être une date égale à demain.