ZF-2876: Override locales with default
Description
Add a way to override auto locales with set ones. This feature would allow all classes which make use of I18N to have a fix locale set instead of using the detected one.
Add a way to override auto locales with set ones. This feature would allow all classes which make use of I18N to have a fix locale set instead of using the detected one.
Comments
Posted by Ben Scholzen (dasprid) on 2008-04-27T10:37:46.000+0000
What's the problem with my patch, Thomas?
http://framework.zend.com/issues/secure/…
Posted by Thomas Weidner (thomas) on 2008-04-27T11:08:53.000+0000
It takes only in account the Zend_Locale class itself. But this behaviour must also be integrated in all other locale aware classes at the same time.
And we will reuse the setDefault function instead of creating a new one.
Posted by Wojciech Naruniec (wojciech) on 2008-06-17T14:46:47.000+0000
In my opinion it should be marked as major and resolved ASAP. Now if you would like to override locale you have to pass your own locale to all of the constructors and static methods of Zend_Currency, Zend_Date, Zend_Measure etc.
I think the simplest way to resolve it is use of some static flag to disable all automatic detections of locale in favor of use default value.
Posted by Ben Scholzen (dasprid) on 2008-06-17T15:09:06.000+0000
That's exacly what my patch was doing.
Posted by Vincent de Lau (vdelau) on 2008-06-18T03:33:55.000+0000
Current setDefault() behaves as a fallback option / option of last resort. self::$_Default in 1.5.2 is never used to set the locale directly, it is only returned as last option in getDefault().
I was expecting it to set the locale to use when no other is specified in the constructor.
Posted by Vincent de Lau (vdelau) on 2008-06-18T04:03:03.000+0000
I've patched my Locale.php as follows to cover my needs:
Posted by Ben Scholzen (dasprid) on 2008-06-18T05:48:25.000+0000
That patch is not really good Vincent, as it breaks B/C
Posted by Vincent de Lau (vdelau) on 2008-06-18T06:27:13.000+0000
I know, this is just a temp fix for my situation. I hate making big patches to ZF in anticipation of coming fixes. Although this brakes functional B/C, my code won't break (give errors) after a framework update. If Zend_Date and co wheren't calling Zend_Locale directly, I would have subclassed it.
Anyway a warning for others: DON'T USE THE ABOVE PATCH, unless you know exactly what is does and what it breaks!
I've send a mail to fw-i18n@lists to discuss this and some other items.
Posted by Thomas Weidner (thomas) on 2008-06-18T13:12:45.000+0000
As you may have mentioned I added this new feature as request and I am also aware of the problems.
And as BC breaks are not allowed and I had not the time to do some deeper research on this feature I have not implemented it for now.
Please be patient.
I am very restrictive to patches as the I18N core has constraints to almost half of the Zend Framework and not only to the locale class itself as I have to compare the change to all components and their usage. This is not a simple task.
It will be implemented, but not in the next few days. It will be integrated in the next release after 1.6.
Posted by Thomas Weidner (thomas) on 2008-08-27T04:49:51.000+0000
A default locale has been added within trunk. Use setDefault() / getDefault() and 'default' as autosetting.
Beware: As mentioned this is a BC break. Be aware of possible merging problems when using the old auto behaviour.
Posted by Wil Sinclair (wil) on 2008-09-02T10:38:50.000+0000
Updating for the 1.6.0 release.