Book Image

CakePHP 2 Application Cookbook

By : James Watts, Cake Software Foundation, Inc.
Book Image

CakePHP 2 Application Cookbook

By: James Watts, Cake Software Foundation, Inc.

Overview of this book

Table of Contents (20 chapters)
CakePHP 2 Application Cookbook
Credits
Foreword
About the Authors
About the Reviewer
www.PacktPub.com
Preface
Index

Using the I18n shell


CakePHP provides a powerful console shell to help you in the first steps of internationalizing your application. Addressing i18N is not an easy task, as there are many details to consider, such as dates and times, number and currency formats, dynamic content translation, and distinct dialects.

In this recipe, we're going to use the CakePHP I18n shell to prepare our application for translations with a simple flash message example.

Getting ready

First, we'll define a base language for our application. For this, we'll assume the base language will be English. All of your static content will then be displayed using any of the __() functions.

We'll assume you have the gifts and recipients tables created from our previous recipes, but also ensure that you create all of the CRUD-related classes using the bake shell as follows:

Console/cake bake all Gift
Console/cake bake all Recipient

Then, in your app/Controller/RecipientsController.php file, add the following method:

public function...