Prev | Current Page 342 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

We will use our configuration INI file to store this as shown in listing 14.7.
Listing 14.7: Setting locale information in config.ini
languages.en = en_GB A
languages.fr = fr_FR A
languages.de = de_DE A
A The short form text is the key to the full locale
The list of valid language codes and their associated locales are now available in the $config object that is
loaded in the bootstrap and then stored in the Registry. We can retrieve the list of supported language codes
using:
$languages = array_keys($config->languages->toArray());
To allow the user of the language codes within the address, we need to alter the routing system to account
for the additional parameter. The standard router interprets paths of the form:
/{controller}/{action}/{other_parameters} or
/{module}/{controller}/{action}/{other_parameters}. A typical path for Places is:
/place/index/id/4 which calls the index action of the place controller with the id parameter set to 4. For
our multi-lingual site, we need to introduce the language as the first parameter, so that the path now looks like:
/{language}/{controller}/{action}/{other_parameters}. We??™ll use the standard two
character forms for the language, so that a typical path for the German language version of Places is
/de/place/index/id/4.


Pages:
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
Teksty piosenek pomoce dydaktyczne meble do sypialni ATC Abs