ZF-6878: Zend_Application_Resource_Locale can't initialize one particular local


You can not define one particular local variable with application.ini and Zend_Application_Resource_Locale. The default value had no impact with the standard search order.


In the locale resource there is a default locale set (Zend_Locale::setDefault(....) ). After that, the locale is created using: $this->_locale = new Zend_Locale();

This will not take the given locale to be used! When creating a new locale this way, it will follow the rules for 'auto detection' and not used the previously setted default.

So, wasn't it meant to be:

(line 66:) $this->_locale = new Zend_Locale($options['default']);

in this case the used locale in the application.ini is used.

But maybe I'm totally wrong ;-)

(well, the actual locale in the application.ini isn;t use for now....)

Please read the manual chapter about Zend_Locale. setDefault() sets a default fallback locale and not the locale which will be used for autodetection.

Zend_Locale() uses browser detection. This is not an issue, just a misunderstanding of how things work.

It's not a misunderstanding, I've already looked the Zend_Locale code. Even if the autodetection is recommended, there is a method to change the research order. I know the default variable acts in last resort after the browser and the environment. I'm saying that the Zend_Application_Resource_Locale should enable to configure according to the needs. For a project, you can have one single language or a language chosen by the user. Zend_locale is very used among the other components via the register. Therefore, we should be able to define it. Besides, the autodetection can choose a simple locale ie a country without the region. Yet, some components need the information given by the region, such as the currency or the translation.

Just for information: * A locale with only a country is no locale... "US" itself is no locale * Translation does not need region... translation work also when only the language is set

Maybe it's not a locale but Zend_Locale will be instanced with it. With firefox and the browser detection, I get an instance of Zend_Locale with fr and not fr_FR. The translation doesn't need the region in order to work, but in some cases there are differences like betwen british and american english.

@Benoît: A locale MUST have a language and MAY contain additional data.

Even firefox does not allow to set a locale which hold only a country and no language. This is a wrong information.

The locale "fr" means "french" which is a language and does not mean "France" the country... "fr_CA" is french for the country Canada but does not mean "France" with the language "Catalan".

And for translation the language is enough... when you want to use region aware translation then you have, of course, to give also the country additionally to the language. But this has no effect to what I said before.

  • "US" is no locale
  • "en" is a locale
  • "en_US" is a locale for a special region

The original issue has been fixed with r16189. For your 'issues' with zend_locale itself please open a separate issue (which probably isn't an issue btw).

When the application.ini file sets a default (fall-back) locale, Zend_Application_Resource_Locale incorrectly creates the locale object with it. This default should be set before creating the locale object and then create the object using automatic locale discovery.

For instance, the getLocale() function should be modified similar to this: public function getLocale() { // Zend version incorrectly ignores HTTP_ACCEPT_LANGUAGE value when create locale object if (null === $this->_locale) { $options = $this->getOptions(); if (isset($options['default'])) { // Set the fall-back locale Zend_Locale::setDefault($options['default']); } else { // Should the web server's locale be set as a default when none provided? } // Now create the locale with automatic locale discovery enabled (the default method) $this->_locale = new Zend_Locale();

        $key = (isset($options['registry_key']) && !is_numeric($options['registry_key']))
            ? $options['registry_key']
            : self::DEFAULT_REGISTRY_KEY;
        Zend_Registry::set($key, $this->_locale);
    return $this->_locale;


-Please open a new issue for that.-

That has just been done, thank you.