CakePHP, i18n and poedit tutorial for multilanguage
Follow these steps for CakePhP 2.4.6 or similar. Preparations: you already baked your application and have your __() functions in your views.
- open console and navigate to your app folder (like htdocs\newwebsite\
- type "app\console\cake" followed by "i18n extract" and enter
That will have cake open all your models, controllers and views and look for the entries in the __() functions. It will put them into a file called "default.pot"
- If cake asks you for parameters, you mostly can jus hit enter until baking over.
- get poedit from http://poedit.net/
- start poedit
- "New from POT" from the main menu
- choose the file named "default.pot" which is located in subfolders "\app\Locale" (its been placed there by the bake i18n command)
- poedit will ask you for 1) a language and 2) a location of the new translation
- in the dialog box, create a subfolder of "Locale" with the name "deu" if you aim for german. NOT "ger"!
- create another subfolder in "deu" called "LC_MESSAGES"
- place the file unter the name of "default.po" there
- open "app\Config\core.php"
- enter the new line somewhere: "Configure::write('Config.language', 'deu');"
- save everything and fire up your application
- choose any term in poedit and click on it. translate it and either hit ctrl+enter or ctrl+arrow up / down. ctrl+s and reload your browser.
Youre finished. Repeat if you changed your application. Its easy, as you can tell potedit to read the new pot file and compare it to the already handeled translation.
For any new lanuage, repeat from "New from POT". And maybe set the language var in the users profile or fetch it from the browser.