Context
I want to translate my app in french and english. I followed exactly the CakePHP 3 documentation but it is not working.
What I did so far
For my development, I'm using a vagrant box to easily get up and running with CakePHP 3. This box is named vagrant-chef
/config/bootstrap.php
I modified the line 100 to use french as the default language.
ini_set('intl.default_locale', 'fr_CA');
/src/Controller/PagesController
I added this method to the default PagesController
public function initialize() {
I18n::locale('en');
}
/src/Template/Pages/home.ctp
I added these 2 lines
<?php echo __('Hey, bonjour'); ?>
<?php echo __('Je teste la traduction'); ?>
.pot file generation
From the terminal, I input this command bin/cake i18n extract
. CakePHP created 2 files in /src/Locale/
. Those files are cake.pot
and default.pot
. I translated the default.pot file like that:
...
msgid "Hey, bonjour"
msgstr "Hey, hello"
...
Locales directory structure
The /src/Locale
file looks like this now:
/en
/default.pot
Despite my attempts to translate my app, I didn't get anything working. I supposed it was a Cache problem, so I deleted the files in /tmp/cache/persistent/
.
Thanks.