Prev | Current Page 332 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

One
gotcha is that setlocale() is not thread-safe and the strings you need to set are inconsistent across
operating systems, so care must be taken using it. Also, some functions like money_format() aren??™t available
on all operating systems, for example Windows. The Zend_Locale component is intended to mitigate these
issues and also provides additional functionality like normalization.
Now that we know a little about what localization and internationalization is, let??™s look at what the Zend
Framework provides to make the process of creating an international website easier. We will start by looking
at Zend_Locale??™s ability to convert numbers and dates before moving on to investigate Zend_Translate??™s
functionality for providing translated text.
14.2 Using Zend_Locale and Zend_Translate
Zend_Locale and Zend_Translate are the key components of the Zend Framework for providing a multilingual
worldwide website. Other components that are aware of localization are Zend_Date, Zend_Calendar
and Zend_Currency. Let??™s look at Zend_Locale first.
14.2.1 Zend_Locale
To select the correct locale is as easy as:
$locale = new Zend_Locale('en_GB');
This will create a locale object for the English language, GB region. We can also create a Zend_Locale
object for the locale of the user??™s browser using:
$locale = new Zend_Locale();
The locale object can then be used for translating lists of common strings such as countries, units of
measurement and time information such as month names and days of the week.


Pages:
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
prezenty ręcznik hotelowy Abs Adamski ATC