2

I have an application with CakePHP 3. My app is in french and english.

In the function initialize() of my UsersController, i said :

'authError' => __('Vous devez vous identifier pour accéder à cette zone.')

In my en_US/default.po (generated with poedit) i have :

#: Controller/SavsController.php:35 Controller/UsersController.php:29
msgid "Vous devez vous identifier pour accéder à cette zone."
msgstr "Login to access this area."

But the translation is not working... This message is always in french, why ? Anyone already had this problem ?

I set the default language to 'fr_FR' in my config, i have a generated .pot and po files for fr_FR and en_US. When i switch language in my app, all works good except this flash message...

The others message works good, ex :

#: Template/Pages/home.ctp:44
msgid "Accès Espace Client"
msgstr "Customer Area Access"

The code of my initialize function :

parent::initialize();
$this->loadComponent(
    'Auth', [
        'loginRedirect' => [
            'controller' => 'Users', 'action' => 'home'
        ], 'logoutRedirect' => [
            'controller' => 'Users', 'action' => 'logout'
        ], 'loginAction' => [
            'controller' => 'Users', 'action' => 'login'
        ], 'logoutAction' => [
            'controller' => 'Users', 'action' => 'logout'
        ],
        'authError' => __('Vous devez vous identifier pour accéder à cette zone.'), 
        'authenticate' => [
            'Cotral' => [
                'fields' => [
                    'email' => 'email', 'password' => 'password'
                ]
            ],
        ],
    ]
);

Thanks for the help ;)

Cotral Lab
  • 45
  • 7

1 Answers1

2

You probably switch the language in beforeFilter(), which is called after initialize().

You can either implement your language switching logic before you load the AuthComponent, or update the value of the authError key in beforeFilter.

nanoman
  • 1,069
  • 12
  • 27