Search code examples
phplinuxsymfonygettext

Error symfony in login page - Warning: gettext()


When I go to my page login in localhost :

mylocal.com/app_dev.php/login, I have this error :

enter image description here

An exception has been thrown during the rendering of a template ("Warning: gettext() expects exactly 1 parameter, 3 given").

On this ligne of template :

<div class="form-group">
   <input type="text" id="username" name="_username" value="{{ last_username }}" required="required" placeholder="{{ 'security.login.username'|trans }}" class="form-control" />
</div>

My composer.json :

"require": {
        "php": ">=7.1",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "friendsofsymfony/jsrouting-bundle": "^1.6",
        "friendsofsymfony/user-bundle": "2.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "knplabs/doctrine-behaviors": "^1.4",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "symfony/assetic-bundle": "^2.8",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "3.4.*",
        "twig/twig": "^2.0",
        "twig/extensions": "^1.5"
    },

My version :

php: PHP 7.2.2-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 6 2018 16:11:23) ( NTS )

apache: Server version: Apache/2.4.18 (Ubuntu)


Solution

  • If you use Twig-extensions, it may com from the i18n Extension. So to quickly fix it, juste disable the i18n Extension.

    http://twig-extensions.readthedocs.io/en/latest/i18n.html