PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Get the locale by giving a territory

When you only have the territory or country then it's also possible to get a locale from that information. You can manually search if there is a locale for this territory by using getLocaleToTerritory(). This method returns a locale for the given territory or NULL when there was has no locale been found.

Example 554. getLocaleToTerritory

<?php
$locale 
Zend_Locale::getLocaleToTerritory('US');
// returns 'en_US'

Uppercase territories

When you know that you are using a territory, then you should uppercase it. Otherwise you could get an in your eyes false locale in return when you use other methods. For example: When you give "om" then getLocaleToTerritory() returns you "ar_OM" as it knows that you mean a territory. But all other methods will return "om", as it's also a language.

So when you know that the given string is a territory, eighter use getLocaleToTerritory() yourself before creating a locale, or uppercase the input.

Zend Framework