> before I post these as issues on the Issue Tracker, I wanted to quickly
> address a few problems I've encountered after upgrading to 1.8.0. The
> application in question used to work perfectly fine using 1.7.x.
>
> First error I encountered was a "cache_dir is not writable" exception.
> After
> some time trying to check why the cache_dir I was setting for my own
> application would break all of a sudden, I found that Zend_Locale is the
> culprit, obviously it's using a cache of its own, and the default folder
> wasn't writable, so I had to set the cache_dir like so:
Zend_Locale does only then use a cache itself when you don't set any.
When you set a cache as demanded in the manual, then your cache is used.
Using no cache when working with the I18N core is really a no-go.
> Zend_Locale_Format::setOptions(array('cache' => $myWritableCacheDir));
>
> With that out of the way, the next obstacle was an empty $locale string
> passed to the Int and Float validators ("Locale '' not found"). The docs
> say
> that these methods are using the application-wide locale, which I'm
> setting
> in the bootstrap:
>
> setlocale(LC_ALL, 'de_DE');
> $locale = new Zend_Locale('de_DE');
> Zend_Registry::set('Zend_Locale', $locale);
> Zend_Locale::setDefault('de_DE');
> Zend_Locale_Format::setOptions(
> array('cache' => $myWritableCacheDir, 'locale' => $locale));
No, you're wrong.
This message means not that you gave a null as parameter, it means that you
gave a empty string ('') as locale.
The question is not what you set into registry, the question is how you
initiate the validator which you did not show.
Also to note:
You set the locale object to registry, but you change it after you saved it
to the registry.
This means that the changes done afterwards are not within the registry.
> When adding validators to a Zend_Form_Element using the addValidator()
> method, it is unclear to me on how to pass in a locale, so for now I
> worked
> around it by extending Zend_Validate_Int and specifically setting the
> locale.
addValidator accepts as optional parameter a array of options for this
validator.
But you could also call setLocale on that validator like described in the
manual.
Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com