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

Issue Type: Bug Created: 2009-06-01T13:02:06.000+0000 Last Updated: 2009-12-01T12:24:22.000+0000 Status: Resolved Fix version(s): - 1.8.4 (23/Jun/09)

Reporter: Benoît Durand (intiilapa) Assignee: Dolf Schimmel (Freeaqingme) (freak) Tags: - Zend_Application

Related issues: - ZF-8435



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.


Posted by Sven Franke (snefit) on 2009-06-19T11:49:00.000+0000

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....)

Posted by Thomas Weidner (thomas) on 2009-06-19T13:22:31.000+0000

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.

Posted by Benoît Durand (intiilapa) on 2009-06-20T08:19:02.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-06-20T09:08:49.000+0000

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

Posted by Benoît Durand (intiilapa) on 2009-06-20T09:38:18.000+0000

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.

Posted by Thomas Weidner (thomas) on 2009-06-20T10:34:10.000+0000

@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

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-06-20T11:44:20.000+0000

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).

Posted by Jolly Blume (jollyblume) on 2009-12-01T12:12:42.000+0000

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;


Posted by Dolf Schimmel (Freeaqingme) (freak) on 2009-12-01T12:18:10.000+0000

-Please open a new issue for that.-

That has just been done, thank you.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.