O'Reilly logo

CakePHP 2 Application Cookbook by Jorge González, James Watts

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Translations

Offering your content in various languages is an important step many applications face at some point in their life cycle. Fortunately for you, CakePHP comes well prepared for internationalized applications.

In this recipe, we'll look at how to handle translations in your views, showing the various functions available to deal with different scenarios, and provide a simple interface to the framework's I18n class.

Getting ready

For this recipe, we will create ArticlesController to display a list of articles. So, create a file named ArticlesController.php in app/Controller/ with the following content:

<?php
App::uses('AppController', 'Controller');
    
class ArticlesController extends AppController {
}

We'll also need a table of articles, so create ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required