Prev | Current Page 345 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

php. The main functionality that it performs
is:
Load language file containing array of translations
Instantiate Zend_Translate object for the selected language
Assign language string and Zend_Translate object to the controller and view.
All this is done in the init() function, however we need to ensure that the action helper knows the directory
where the language files are stored and also the list of languages available. This information is known in the
bootstrap file and so we pass it to the action helper using the constructor. This is shown in listing 14.9.
Listing 14.9: Language action helper to load Zend_Translate object
class Places_Controller_Action_Helper_Language
extends Zend_Controller_Action_Helper_Abstract
{
protected $_languages;
protected $_directory;
public function __construct($languages, $directory)
{
$this->_dir = $directory; A
$this->_languages = $languages; B
}
public function init()
{
// actual work done here
}
}
A Translation files are stored here
B List of languages available
The action helper is loaded in the bootstrap in just the same way as the ACL helper in chapter 6, only this
time we need to pass in the list of languages and the directory where the translation files are stored. For Places,
Licensed to Menshu You

Pages:
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
motoryzacja szkoła narciarska wyrejestrowanie samochodu legnica obciążniki Wczasy nad morzem