Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cakephp 3 i18n not working

I have cake 3 fresh installation.

I have a simple po file in this location src/Locale/de_DE/default.po with the following content.

msgid "test"
msgstr "test in german"

On my home page template file I have simple <?php echo __('test'); ?>

I need to set the locale on the fly, so I add this to my AppController's beforeFilter(or initialize) - I18n::locale('de_DE'); however test is not being translated. I can't figure out, what Im missing. I tried renaming all to iso2 - de, but it did not translate either.

Thanks

like image 397
dav Avatar asked Jun 13 '26 18:06

dav


1 Answers

Open your Terminal, cd to your project folder (the one which contains the bin folder) and type:

bin/cake cache clear_all

That's all. Refresh your page right after. One last thing, be sure to place your .po files in:

Locale/de_DE/your_translations.po

I like to use POEdit to manage my translations. Cheers.

like image 106
Guillaume Pommier Avatar answered Jun 17 '26 10:06

Guillaume Pommier