How to localize "input not valid"?

How to localize "input not valid"?

pisislerpisisler Posts: 125Questions: 24Answers: 1

Searched for it but couldn't find. Is it hard coded somewhere? Because there is no appropriate entry for it in language file. I know there is message() method in validation, but implementing it into every single field with the same message looks not nice.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    I think you're referring to the field validation in the server-side scripts - see here. That would need a change to the server-side scripts.

    Colin

  • pisislerpisisler Posts: 125Questions: 24Answers: 1
    edited April 2021

    Yes, I was referring to that. See this part in the documentation you referred:

    ->message( string ): the error message to show if the validation fails. This is simply "Input not valid" by default, so you will likely want to customise this to suit your needs.

    I simply want to localize that "default" (which is to be "Input not valid") rather than calling message() for multiple times for different fields with exactly the same content.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599
    Answer ✓

    That message is in two places in the Editor package, see here:

    lib/Editor/Validate.php: 'message' => 'Input not valid',
    lib/Editor/ValidateOptions.php: private $_message = 'Input not valid';

    If you edit those two files, that will change the default,

    Colin

  • pisislerpisisler Posts: 125Questions: 24Answers: 1

    Then it is hardcoded yes. If I need to setup a multi language environment, I need to call message() rather than editing core DataTables files. Thank you @collin

This discussion has been closed.