jeudi 2 juin 2016

Laravel localization of validation rule 'before' and 'after' with parameter like 'today/tomorrow'

Lets assume I have this rules in my model:

public $rules = [           
        'a_date'  => 'after:today',
        'b_date'  => 'before:today',
    ];

And I have this string in my project\resources\lang\en\validation.php:

    'after' => 'The :attribute must be a date after :date.',
    'before' => 'The :attribute must be a date before :date.',

I translate them into some language in project\resources\lang\some-language\validation.php

    'after' => ':attribute *somelanguage* :date.',
    'before' => ':attribute *somelanguage* :date.',

But when I hit validation error in my app I see string like that: *field* *some language* today
(for example in Russian:Поле a_date должно быть раньше чем today)

So the question is: How and where to replace this today(and any other predifined words like that) to desired localization?

PS: I could use a custom validation as stated in docs http://ift.tt/1t3Hwlf
but it only aplied to certain fields and I wish it to replace today whenever I use it in any of fields.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire