I'm using CakePHP v2.5.6 and I'm following this documentation on CakePHP localization. I've read it 100 times but it still isn't working!
Using the cake console i18n
task, I've created the following files...
app/Locale/default.pot
app/Locale/fra/LC_MESSAGES/default.po
app/Locale/fra/LC_MESSAGES/default.mo
...I used Poedit to translate a few strings (for testing) purposes:
In bootstrap.php I have:
Configure::write('Config.language', 'fra');
(I've also tried placing it in my AppController's beforeFilter()
which also didn't work)
In my view I have:
<?php
Debugger::dump( Configure::read('Config.language') );
Debugger::dump( CakeSession::read('Config.language') );
echo __('Find a Place');
?>
But when I load the page I just see:
'fra'
null
Find a Place
Why?????!!!!!!
Update 1 @ndm raised some concerns about caching...
In my persistent cache the following files appear:
.../temp/cache/persistent/myapp_cake_core_cake_fra
.../temp/cache/persistent/myapp_cake_core_default_fra
.../temp/cache/persistent/myapp_cake_core_file_map
.../temp/cache/persistent/myapp_cake_core_method_cache
Update 2 Following @ndm's advice, I hacked out everything but one translation in the .po file and it WORKED!
# LANGUAGE translation of CakePHP Application
# Copyright YEAR NAME <EMAIL@ADDRESS>
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"POT-Creation-Date: 2014-11-20 11:30-0500\n"
"PO-Revision-Date: 2014-11-20 11:43-0500\n"
"Last-Translator: SDP\n"
"Language-Team: <EMAIL@ADDRESS>\n"
"Language: fr_CA\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 1.6.10\n"
#: View/Elements/nav--main.ctp:3
#, fuzzy
msgid "Find a Place"
msgstr "Trouver une place"
Clearly something is wrong with my file, but it's weird because it's a brand new file generated by Poedit AND it passes the "Validate" function without problems. It just says that there are lots of entries that aren't translated yet.
The lines I removed from the file look like this:
...
#: Controller/FavoritesController.php:38;73;101
msgid "Invalid favorite"
msgstr ""
#: Controller/FavoritesController.php:53;77
msgid "The favorite has been saved."
msgstr ""
#: Controller/FavoritesController.php:56;80
msgid "The favorite could not be saved. Please, try again."
msgstr ""
...
Anything wrong with that?