We can also retrieve the
language and region using:
$language = $locale->getLanguage();
$region = $locale->getRegion();
Clearly, we can then use this information to provide websites in the correct language with the right
formatting of dates, times and currencies which will make our user feel right at home. Let??™s look at numbers
first.
Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co. 37
Dealing with numbers
The most significant regional problem with numbers are that some countries use the comma to separate out the
decimal places from the whole number and some countries use the point character. If your website allows the
user to enter a number, then you may have to convert appropriately. This is known as normalization. For
example, consider a form that asks someone to enter their monthly insurance costs in order to try and provide a
cheaper quotation. A German user may type in the number 3.637,34 (three thousand, six hundred and thirty
seven Euros and thirty four cents) which you need normalize to 3637.34. This is achieved using the code
shown in listing 14.1.
Listing 14.1: Number normalization with Zend_Locale
$locale = new Zend_Locale('de_DE'); A
$number = Zend_Locale_Format::getNumber('3.
Pages:
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345