Issues

ZF-3980: Zend_Locale unable to use user's browser locale settings

Issue Type: Bug Created: 2008-08-18T02:19:51.000+0000 Last Updated: 2008-09-02T10:39:14.000+0000 Status: Resolved Fix version(s): - 1.6.0 (02/Sep/08)

Reporter: Costin Bereveanu (costinb) Assignee: Thomas Weidner (thomas) Tags: - Zend_Locale

Related issues: Attachments:

Description

In the constructor of Zend_Locale, each protected autodetected locale is populated calling getDefault(mode, false). Using false as the second argument pushes the environment autodetected locale over the browser's one. So if I set Romanian in the browser, an English locale comes down from the environment setting and becomes the first choice.

If I'm missing something, my bad. But at this point I can't seem to be able to use the user's browser locale. In my opinion, in Zend_Locale's constructor (and I think in another place in that file), the getDefault method should be called with true as the second argument.

Suggested fix following; the _auto member would be ok to be built after the original behavior, merging browser and environment. But _browser and _environment should only contain those locales.

Index: library/Zend/Locale.php

--- library/Zend/Locale.php (revision 27) +++ library/Zend/Locale.php (working copy) @@ -173,8 +173,8 @@ { if (empty(self::$_auto) === true) { self::$_auto = $this->getDefault(null, false); - self::$_browser = $this->getDefault(self::BROWSER, false); - self::$_environment = $this->getDefault(self::ENVIRONMENT, false); + self::$_browser = $this->getDefault(self::BROWSER, true); + self::$_environment = $this->getDefault(self::ENVIRONMENT, true); if ((empty($locale) === true) and (empty(self::$_auto) === true) and (empty(self::$_default) === true)) { require_once 'Zend/Locale/Exception.php'; @@ -830,8 +830,8 @@ if (empty(self::$_auto) === true) { $temp = new self($locale); self::$_auto = $temp->getDefault(null, false); - self::$_browser = $temp->getDefault(self::BROWSER, false); - self::$_environment = $temp->getDefault(self::ENVIRONMENT, false); + self::$_browser = $temp->getDefault(self::BROWSER, true); + self::$_environment = $temp->getDefault(self::ENVIRONMENT, true); }

     if ($locale === 'auto') {

Taken a look at the trunk version - seems much closer to what I imagined ;) Haven't tested it yet but you may close this issue - seems pretty much solved. Thanks!

By the way, why can't I post comments?

Comments

Posted by Thomas Weidner (thomas) on 2008-08-25T07:07:57.000+0000

The I18N core can changed 4 weeks ago but is not allowed to be integrated until 1.7. Can you please try if you have problems with actual trunk and give us feedback ?

Posted by Thomas Weidner (thomas) on 2008-08-25T14:48:16.000+0000

Fixed in trunk with new implementation

Posted by Wil Sinclair (wil) on 2008-09-02T10:39:14.000+0000

Updating for the 1.6.0 release.

Have you found an issue?

See the Overview section for more details.

Copyright

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

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

Contacts