ZF-2310: Add an default locale to Zend_Locale


Add an default locale which will be used in the case that wether the browser nor the server provides a locale.

In this case the exception would not be thrown and instead the default locale would be used.


First to solve the detection problems before handling the undetectable "C" locale.

I just come across this issue. I work on a MacBook Pro and I created a simple Zend_Service_Delicious script.

This issue causes Zend_Service_Delicious to fail when called via shell on my Mac. I posted all details here ZF-2318.

About this issue I [… a topic] that apparently describes the same problem. I vote +1 for a default locale setting on detection failure.

Sorry, but Zend_Service_Delicious has NOTHING to do with Zend_Locale. You can solve your problem this way:

setlocale(LC_ALL, 'it_IT');
$service = new Zend_Service_Delicious();

In general the problem is that Zend_Service_Delicious does not handle exceptions from Zend_Locale properly.

Hi Thomas,

I know that the specific Zend_Service_Delicious issue has nothing to do with this Zend_Locale issue. This is why I posted ZF-2318 under the proper Zend_Service_Delicious category.

However, my comment was to point out how executing Zend_Locale under Mac Osx via shell causes

setlocale(LC_ALL, 0);

to return C string instead of a valid locale variable and, in general, it causes Zend_Locale to throw an Exception. In this specific issue, my comment was a kind of agreement to your 'default locale' suggestion. :)

I also noticed that Zend_Locale autodetection calls this function

     * Returns the locale which the framework is set to
    public function getFramework()
        $languages = array();
        return $languages;

but it seems closed to itself without any possibility of adding defaul languages without extending the class itself. Is it a bug or a design decision? (May be this should be a different issue?)

PS. About Zend_Service_Delicious, I already used setlocale(LC_ALL, 'en_US'); as a workaround before and it works but I think something should be improved in the class itself, this is why I opened a new issue at ZF-2318.

The getFramework() method was added because when this proposal was made there was a discussion of adding a generic framework wide config.

There is still a proposal which aims to do so... this is what this method was made for. As the related proposal is still not implemented the method is still empty.

This is no bug, it was a design decision of the dev-team.

{quote}As the related proposal is still not implemented the method is still empty.{quote}

Thanks for your clarifications, Thomas.

Implemented with SVN-7175.