Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How can I translate/custom Phalcon's error messages?

Phalcon has some built in error messages, like this

    Value of field 'phone' doesn't match regular expression

I'm working on a multi-lang project, I want to make these error messages can be multi-lang, too.
Are these messages translatable?


I am developing multi-lang project too.

  • When you define your validators you can pass your custom message values e.g.


use Phalcon\Mvc\Model\Validator\PresenceOf;

class Subscriptors extends Phalcon\Mvc\Model

  public function validation()
      $this->validate(new PresenceOf(array(
          'field' => 'name',
          'message' => 'The name is required'
      if ($this->validationHasFailed() == true) {
          return false;

  • If you are asking about model messages, there is an issue with Phalcon's default notNullValidators. It is described here

  • I am suggesting you using gettext extension for translations. It has the best performance and supports plurals. Plurals are important if you are interested in generating high quality translations.