Localisation not working on CakePHP 4

Hello, it’s been several weeks since I got the localization to work with CakePHP 4. I followed the documentation, but it doesn’t work.

I have the src /Locale/fr_FR folder in my app containing a simple “default.po” file with these few lines:

msgid "Awesome"
msgstr "Génial!"

msgid "Home"
msgstr "Accueil"

In my app.php:

defaultLocale' => env('APP_DEFAULT_LOCALE', 'en_US'),

In my AppController.php

I18n::setLocale('fr_FR');

__(‘Awesome’); return always “Awesome”, same for problem for __(‘Home’);

Clearing the cache have no effect.

Thanks for your help :slight_smile:

Try putting your locales folder in the /resources folder, not the /src one. Also make it lowercase l - just in case!

Thanks it work now :slight_smile:

I have the same problem. I followed the manual. The paths are all ok. If I set locale in AppController.php all numbers get properly formated according to locale. The problem is, that text don’t get translatet using <?= __("Some string") ?>.

Is there any tutorial or hint, how can I debug or search what can be wrong?

The problem was wrong wrong permissions on folders and files.

1 Like